What is the best way to synchronize multiple workstations using cpython with several packages in Rhino8. I tried
C:\Users\myuser1\.rhinocode\py39-rh8>./python -m pip freeze > rhino8_cpython_requirements.txt
and on a different workstation
C:\Users\myuser2\.rhinocode\py39-rh8>./python -m pip pip install -r rhino8_cpython_requirements.txt
This produced several errors. What is your recommendation to synchronize between workstations?
Is it also possible to use a system wide cpython installation? If multiple users use the same workstation, I have to install the identical python environment for each user.
What are the install errors you are seeing?
Hi @eirannejad,
sorry for not responding so far. Today I tried a fresh Rhino 8 installation with the same build on another workstation. This time I did not have any issues with the requirements file. My requirements file consists of more than 240 packages.
During the next weeks I will try it on further workstations during our Rhino 8 migration and let you know, if I receive any errors with this procedure.
Hi @eirannejad,
at the moment I try to build a simple installer to setup multiple workstations with the identical cpython environment. I just want to let you know what I came across.
- I had some issues during pip install -r requirements.txt. I think it had something to do with permissions. Adding the flag --user to pip solved the problem. This extends the python search path with C:\Users%username%\AppData\Roaming\Python and installs all site packages to this location. Unfortunately, this folder is not deleted, if one uses the option in the Script Editor to reset the python environment. I had to delete this folder manually.
- Using the comment version (i.e. # r: numpy) to install all packages seems not to work for us as an alternative. We want to have specific versions of packages throughout our company with each release. I can use # r: numpy==1.23.5 for example, but with the next line # r: pandas==2.1.1 the version information of numpy is ignored and a newer numpy version might be installed, because this seems to be a new individual pip install run in the background. The Script Editor has the option to list the installed packages. That list does not seem to be updated, if this happens. I had to use
import numpy print(numpy.__version__)
to get the right information of the installed package. - I would like to install all necessary packages, extend the search path, do subversion checkouts at different locations for colors, toolbars, grasshopper and python packages. At the moment I have to install Rhino, open the Script Editor to initialize the python runtime and than run the python installer script, which uses # r: svn in the main script and pip in an os.system call to
C:\Users\%username%\.rhinocode\py39-rh8\python
to install all packages with dedicated version numbers. Do you have a better idea to install everything? I also thought about installing everything on one workstation and creating a zip archive from the entire python installation and duplicating this to all other workstations. But, I am not sure, if this is causing trouble with Rhino. Is it possible to force Rhino to initialize the python environment directly during the Rhino installation process without opening the Script Editor?
- Open Rhino and Script Editor and let it set up a clean python runtime.
- Make a copy of the
~/.rhinocode/py38-rh8
folder. - There is a python.exe inside this folder. You can use that as
python -m pip install <package>
to install the packages you need undersite-packages
orsite-env
locations (using--target
argument. See Tools > Advanced > Open Python Shell in the script editor for more info) - Once this folder is set up with all the packages you need, pack it up and prepare it to be deployed to the target machines.
- Deploy this package to wherever you want on the target machines
- Use this guide to configure Rhino to use this new directory instead of
~/.rhinocode
folder
This way all the machines running Rhino do not need to set up the python environment since it is already initialized and has all the packages you need. You could even remove pip
at the end and that makes all package installations from scripts fail so no changes can be made to the environment after it is set up.
Let me know if this works. I looked into the pip package listing with wrong version issue and it seems to be related to pip
itself. Somehow it ends up with two numpy package information folders .dist-info
and I think that is throwing it off
RH-87767 Pip lists wrong package version after upgrade
@eirannejad
Thank you for your quick answer. Is it possible to set options such as RhinoCodePlugin.RootPath
and adding toolbars without opening the Rhino UI by for instance editing some xml file?