How to install libraries like SciPy into Rhino 8 beta script editor?

Only NumPy works there as far as I know…and nowhere did I find the option to install other libraries…how to do it please… :slight_smile:

Inside the Python3 editer,

import sys
print(sys.path)

You will find where python is installed.
They actually get a separated python 3.9 for Rhino8 for you (from what I see).

Then go to the directory of that python3.9, inside folder \Scripts you will find pip.
Then go to cmd, cd to the directory of the \Scripts folder (The Rhino8 one).
Then you can pip install whatever you want. I got matplotlib successfully installed in my case.

3 Likes

GREAT!! you are awesome :slight_smile: regarding matplotlib … have you found the way how to show the plot?

plt.show() wouldnt work.
But you can use plt.savefig() to save the image somewhere.
Then use whatever battery you have in GH to read the image by the path. I can’t remember if GH has a native one.

1 Like

This is a real time multiplot you can use as example.
Hope it helps.

Guys you are the best! thank you so much.

I would suggest to use the # r:modulename approach instead, since that will be easier to distribute since you won’t have hard-coded paths.

3 Likes

Hello @martin.petrik ,

How did it go? Could you successfully install pandas and matplotlib on you gh (Rh8)?

Hi Danny -
Can I pls confirm the following 2x points to align my issues on set-up?
i) When you search for the Python executable within the Rhino Script Editor, it renders the Rhino.exe file, i.e.
print(“Python system location”, sys.executable)

C:\Program Files\Rhino 8\System\Rhino.exe

ii) Whether you have any .\activate folder in the Scripts directory?

I’ve got a few issues:

  1. When running pip install, it continues to default to my primary machine installation
  2. When forcing pip install into […] .rhinocode\py39-rh8\ folders (i.e. site-env, site-packages, lib, etc.) --OR–
  3. Appending my system python path into the Script Editor, I receive an error (let’s say calling import numpy) of

“Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there”

Any ideas or feedback is greatly appreciated!

Cheers,

Hi Nathan – I’m confused on this one:

Any # prefix comments out the line inside my Script Editor, rendering this approach useless (unless I’m fundamentally missing something)!

It is a special way for the Python engine to know that such modules are required, and it will install them if they aren’t already installed.

The format is specifically to start with a # so that it isn’t actually executable code.