Updating/changing COMPAS version in Rhino Ipython

I have a couple of questions regarding compas installation for Rhino:

  • I used to run “pip -m compas_rhino.install” for installation, but this gives me the following error:
    pip [options]
    no such option: -m”

Also, using “python -m compas_rhino.install” in a specific conda environment gives me this error:

“Traceback (most recent call last):
File “C:\Users…\Anaconda3\envs\compas-version\lib\runpy.py”, line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File “C:\Users…\Anaconda3\envs\compas-version\lib\runpy.py”, line 109, in get_module_details
File "C:\Users…\Anaconda3\envs\compas-version\lib\site-packages\compas_rhino_init
.py”, line 28, in
import rhinoscriptsyntax as rs # noqa: F401
ModuleNotFoundError: No module named ‘rhinoscriptsyntax’"

  • If I already have a compas in Rhino, how can I modify its version?

  • Is the compas in Rhino related to/affected by the conda environments? If so, how do we know which environment we are working on in Rhino?

If you get that error when running python -m compas_rhino.install, it means you might have python.net installed (or maybe Rhino.Inside) and it is possible to run import Rhino outside of Rhino.

Could you try to uninstall those from that specific environment and see if python -m compas_rhino.install works then? And if it does, please report an issue so that we fix the Rhino detection to make it compatible with Rhino.Inside.

to check which environment is active in Rhino, you can use the following:

import compas_bootstrapper
  • Is it possible to switch to another environment in Ipython?

  • I don’t see any python.net or Rhino.Inside in the list of things installed in any of my environments. Although I am using CodeListener for running the Rhino Ipython in VS (RhinoPython - Visual Studio Marketplace). But this works automatically in all environments (meaning that I did not install it in a specific environment).

happy to help, but i don’t really understand what you are asking…

I still have problem running python -m compas_rhino.install, and regarding to what Gonzalo mentioned, I don’t think that I have any python.net or Rhino.inside installed.

I was also wondering if it is possible to switch envirnoments in Ironpython?

i still don’t really understand but here goes

pip -m compas_rhino.install cannot ever have worked because COMPAS has nothing to do with pip. the only correct command for installing COMPAS in Rhino is python -m compas_rhino.install and all of its variations as described in the docs.

with python -m compas_rhino.install -p xxx you can install all sorts of packages in Rhino (not just COMPAS packages), BUT ONLY IF THOSE PACKAGES ARE COMPATIBLE WITH IRONPYTHON

to install COMPAS packages from a specific environment in Rhino, just activate the environment and run the above-mentioned install command. for example, if you have an environment called “salmo” and in it you have installed COMPAS, but also, for example, compas_cgal, compas_fab, and shapely.

the first step would be to activate the environment

conda activate salmo

then uninstall any previously installed packages just to make sure there is no confusion

python -m compas_rhino.uninstall

then install all the default packages (compas, compas_rhino, compas_ghpython)

python -m compas_rhino.install

finally install all the additional packages you want to be able to use

python -m compas_rhino.install -p compas_fab

note that i did not include compas_cgal or shapely because they are wrappers around C/C++ libs so you cannot use them directly in Rhino. however, they are available through compas.rpc and since you installed COMPAS for Rhino from an environment that contained these two packages, compas.rpc should not have a problem finding them.

when you restart Rhino, the version of compas, compas_rhino, compas_ghpython, and compas_fab installed in the “salmo” environment should now be available.

finally, for future reference…

  • i assume with “IPython” you mean “IronPython”. however, “IPython” is usually used to refer to Interactive Python, which is a special type of interactive session launched in the terminal.
  • make sure to run the above commands from the Anaconda Prompt. if you run them from an IronPython terminal instead, COMPAS might get confused and think that you are actually working inside Rhino, which will make all sorts of conditional imports fail.
  • if you have the RhinoPython code listener plugin installed and you run the install commands from the terminal inside VS Code, perhaps this can also confuse COMPAS into thinking that the current environment is actually inside Rhino.