Rhino 8 - Importing Python 3 Libraries

Hi,

I am having a problem importing python libraries (e.g. pandas) into the script editor. Importing libraries produces the following error:

Traceback (most recent call last):
  File "file:///C:/Users/tdowse/.rhinocode/stage/uxv3fscz.d5v", line 3, in <module>
  File "C:\Users\tdowse\.rhinocode\py39-rh8\site-envs\default-J1ySvk2a\numpy\__init__.py", line 127, in <module>
    _delvewheel_patch_1_5_2()
  File "C:\Users\tdowse\.rhinocode\py39-rh8\site-envs\default-J1ySvk2a\numpy\__init__.py", line 106, in _delvewheel_patch_1_5_2
    import ctypes
  File "<frozen zipimport>", line 259, in load_module
  File "ctypes\__init__.py", line 8, in <module>
ImportError: dynamic module does not define module export function (PyInit__ctypes)

Any ideas on how to fix?

Thanks for your help.

@Thomas_Dowse

I had never seen this particular error before. Let’s double check a few things:

  • What is your Rhino version?
  • What is under C:\Users\tdowse\.rhinocode\py39-rh8\Lib\ctypes
  • What is under C:\Users\tdowse\.rhinocode\py39-rh8\libs
  • What happens if you only have import ctypes in your script?
  • Are there PYTHONPATH or PYTHONHOME environment variables defined on your system?

Hi Ehsan,

Thanks for helping out with this. Responses below.

  • What is your Rhino version?

→ rhino_en-us_8.4.24044.15001

  • What is under C:\Users\tdowse\.rhinocode\py39-rh8\Lib\ctypes

  • What is under C:\Users\tdowse\.rhinocode\py39-rh8\libs

  • What happens if you only have import ctypes in your script?

  • Are there PYTHONPATH or PYTHONHOME environment variables defined on your system?

→ I don’t believe so, I have clipped the system path below and the site environment where it seems to be saving pandas/numpy following install

Thanks again for your help,

Tom

Do you have a C:\Users\tdowse\.rhinocode\py39-rh8\python39.zip file? if yes, then delete the C:\Users\tdowse\.rhinocode\py39-rh8\Lib directory and relaunch Rhino to try again.

Also check the PYTHONPATH or PYTHONHOME under system environment variables in windows

Tried both of these, didn’t seem to work.

Pointed PYTHONPATH and PYTHONHOME at C:\Users\tdowse.rhinocode\py39-rh8

Still getting the same error on script editor

I have the same problem.


The difference is that I have nothing in the site-envs folder.

Ah… my mistake.
I installed numpy and it is solved.

2 Likes

@Thomas_Dowse Would you mind downloading 8.5RC and giving that a try? I need to make sure 8.5 has the same problem for you before I start making any changes to the runtime.

Also make sure you are not running any antivirus/security software that stops Rhino/python from loading the native libraries

@pydeoxy
You can always add a requirement to the top of the script, which will make sure Numpy gets installed:

image

1 Like

Thank you. It’s quite convenient using the new version of Python 3 component in Rhino 8.

@Thomas_Dowse Did my comment about accessing the python runtime help? I am curious to know what other customization options you want to provide to pip?

I am trying to see if we can make more improvements.

Hi Ehsan,

Sorry was out of office all day yesterday.

I have contacted my IT department and apparently we dont have access to Rhino 8.5. Will get them to investigate the antivirus suggestion and get back to you.

Thanks,

Tom

1 Like

Thank you! Looking forward to hearing back.

Ehsan, I just had a chat with ADG IT.

We definitely don’t have access to Rhino 8.5 and no antivirus systems are being triggered during the process.

If you have any other suggestions or need any other information to fix the issue let me know. Thank you!

1 Like

@Thomas_Dowse I did a series of changes in Rhino 8.6 to see if this would resolve your problem with the python deployment. Do you have a machine that you can probably test this on?

Hi Ehsan, my IT department is in the process of confirming that our permissions/security protocols around software install is not impacting the use of the external modules. I’ll get back to you as soon as I hear back from them. Thanks, Tom.

1 Like

@eirannejad I have good news and bad news.

Good news: IT found a security protocol blocking installation of external modules which is now fixed and numpy works as expect. Also, now have access to Rhino 8.5.

Bad news: Pandas (the module we use most commonly to manage data) is now failing under a new error. I have included the error message below.

Change region inside rhino to usa
Fixed this problem for me🤔

1 Like

@Thomas_Dowse This seems to solve the problem

@eirannejad I don’t believe this is a solution that we can roll out to the company.

Will this be fixed in the long term so we can utilise pandas and avoid changing regions?

Thanks,

Tom