Editor - Referencing wrong python package directory

Hi.

Am scripting in Python3, in Rhino8.

The script uses Numpy, and worked well yesterday.

But today, after attempting a package install that went wrong (multiprocessing). The original script doesnt work anymore.

The script uses numpy, and the error I get is:

Traceback (most recent call last):
  File "rhinocode:///grasshopper/1/2ce434ae-a001-4192-9330-7f332b6c3991/ec5f1a54-5332-4f22-a0dd-93a139724fa1", line 18, in <module>
  File "C:\Users\name\.rhinocode\py39-rh8\lib\site-packages\numpy\__init__.py", line 211, in <module>
    from . import lib
  File "C:\Users\name\.rhinocode\py39-rh8\lib\site-packages\numpy\lib\__init__.py", line 33, in <module>
    from . import _polynomial_impl
  File "C:\Users\name\.rhinocode\py39-rh8\lib\site-packages\numpy\lib\_polynomial_impl.py", line 19, in <module>
    from numpy.exceptions import RankWarning
ImportError: cannot import name 'RankWarning' from 'numpy.exceptions' (C:\Program Files\ladybug_tools\python\Lib\site-packages\numpy\exceptions.py)

So it does look like it is trying to use Numpy, from the LBT installation.

FYI the header of the file is:

#! python 3

# venv: site-packages

# r: numpy

I’ve tried restarting, but it seems like my GH/Python setup is corrupted.

Any ideas on how to solve this?

I’d get rid of any multiprocessing remnants (and everything else) and force a reinstall of numpy (and everything else).

Do: cd %USERPROFILE%\.rhinocode\py39-rh8\site-envs then cd into default- whatever it’s called. Delete the directories starting with numpy to uninstall them.

Alternatively without deleting anything, you could try setting up a venv, # env: my_venv I believe, and install all the deps into that instead. But I don’t know if the globally installed packages are still importable from Rhino/Grasshopper’s type of venvs.

Thanks for the answer @James_Parrott, but no cigar (yet)!

My default directory is empty:

Directory of C:\Users\arnkepet\.rhinocode\py39-rh8\site-envs

09.04.2025  09:45    <DIR>          .
18.03.2025  13:28    <DIR>          ..
09.04.2025  09:45    <DIR>          default-9ylcYXdq
               0 File(s)              0 bytes
               3 Dir(s)  308 797 067 264 bytes free

C:\Users\arnkepet\.rhinocode\py39-rh8\site-envs>cd default-9ylcYXdq

C:\Users\arnkepet\.rhinocode\py39-rh8\site-envs\default-9ylcYXdq>dir
 Volume in drive C is Windows
 Volume Serial Number is 4C42-C52C

 Directory of C:\Users\arnkepet\.rhinocode\py39-rh8\site-envs\default-9ylcYXdq

09.04.2025  09:45    <DIR>          .
09.04.2025  09:45    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  308 796 784 640 bytes free

C:\Users\arnkepet\.rhinocode\py39-rh8\site-envs\default-9ylcYXdq>

Is rhino using the LBT directorys for all packages?
How do i find out?
And if so, how to I direct to here?

Ahhh.

So the solution was to delete the corrupted Numpy, as you said, from here:
C:\Users\USER.rhinocode\py39-rh8\Lib\site-packages

1 Like

Good to know - thanks. All the possible directories to import from can be seen on sys.path.