Issues installing pandas on Script Editor

I am trying to use pandas in the new script editor, but I get the following error :

AttributeError: partially initialized module 'pandas' has no attribute '_pandas_datetime_CAPI' (most likely due to a circular import)
Script server execute error:
Traceback (most recent call last):
  File "file:///c:/Users/pablo/Desktop/rhino_code/test-pandas.py", line 2, in <module>
  File "C:\Users\pablo\.rhinocode\py39-rh8\site-envs\default-YVOubeXj\pandas\__init__.py", line 73, in <module>
    from pandas.core.api import (
  File "C:\Users\pablo\.rhinocode\py39-rh8\site-envs\default-YVOubeXj\pandas\core\api.py", line 1, in <module>
    from pandas._libs import (
  File "C:\Users\pablo\.rhinocode\py39-rh8\site-envs\default-YVOubeXj\pandas\_libs\__init__.py", line 18, in <module>
    from pandas._libs.interval import Interval
  File "interval.pyx", line 1, in init pandas._libs.interval
  File "hashtable.pyx", line 1, in init pandas._libs.hashtable
  File "missing.pyx", line 42, in init pandas._libs.missing
AttributeError: partially initialized module 'pandas' has no attribute '_pandas_datetime_CAPI' (most likely due to a circular import)

I can’t find any reference to this issue online; how can I solve this?

I am using Rhino Beta 8.0.23262 2023-09-19

Best,

Pablo

1 Like

please see potential solution

1 Like

i solved it by solving this warning while pip installing the package.
WARNING: The script f2py.exe is installed in ‘c:\users\xxx.rhinocode\py39-rh8\Scripts’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

1 Like

Did someone find a solution?

I did add the directory in path ‘c:\users\xxx.rhinocode\py39-rh8\Scripts’ ‘c:\users\xxx.rhinocode\py39-rh8\site-packages’ and I get the same error

AttributeError: partially initialized module ‘pandas’ has no attribute ‘_pandas_datetime_CAPI’ (most likely due to a circular import)

Any updates on this one?

Not sure if you’re using python a GH component or the script editor, but my co-worker and I have had this problem. We have a fix that sometimes works when using pandas in the GH python component.

  1. verify that pandas is installed in the py39-rh8\ folder
  2. Open the Rhino ScriptEditor (command: ScriptEditor) and run the standard import code:
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
import pandas as pd
  1. Open GH as normal, pandas should now import without the annoying error.

Something about loading it in the ScriptEditor First makes it work.

2 Likes

Still have the same issue. Any updates?

Thanks for sharing! This worked form me.

Thank you for the solution. It worked for me too.

1 Like

My default locale is (‘es_ES’, ‘cp1252’), I get it with
import locale
print(locale.getdefaultlocale())
To install pandas, first open an instance in Grasshopper’s Python 3.9 editor with the following:

import local
locale.setlocale(locale.LC_ALL, ‘en_US’)

Execute it
Without closing Grasshopper
After this, install pandas
pip3.9 install pandas

It is convenient to install the Pyarrow library for pandas
pip3.9 install Pyarrow

To use pandas the following is necessary:
import local
locale.setlocale(locale.LC_ALL, ‘en_US’)
import pandas

1 Like

I didn’t need to use pip3.9 directly, just the #r: , but the key for me was

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

both before installation and before import of pandas.

1 Like

Hi,

@eirannejad Is there any update on this?

I’m still facing the issue with the Python3 scripting component for Grashopper, no matter the locale settings.

I’ve tried en_US.UTF-8, en_US.ISO8859-1, en_US, POSIX, C…etc, none of them worked, either before or after installing Pandas, whether C:\Users\...\.rhinocode\py39-rh8\Scripts is added to PATH or not.

Forcing the import from a different environment with # env: my_conda_env doesn’t seem to work either.

The error remains:

File "C:\Users\...\.rhinocode\py39-rh8\site-envs\default-zcVF8413\pandas\__init__.py", line 77, in <module>
    from pandas.core.api import (
File "C:\Users\...\.rhinocode\py39-rh8\site-envs\default-zcVF8413\pandas\core\api.py", line 1, in <module>
    from pandas._libs import (
File "C:\Users\...\.rhinocode\py39-rh8\site-envs\default-zcVF8413\pandas\_libs\__init__.py", line 18, in <module>
    from pandas._libs.interval import Interval
File "interval.pyx", line 1, in init pandas._libs.interval
File "hashtable.pyx", line 1, in init pandas._libs.hashtable
File "missing.pyx", line 40, in init pandas._libs.missing
AttributeError: partially initialized module 'pandas' has no attribute '_pandas_datetime_CAPI' (most likely due to a circular import)

I’m desperate at this point. Please help.

Looking at this deeper today to see if there is anything I can improve more. It would be nice if you can test 8.8 RC and send me the report from RhinoCodeLogs command after opening script editor

1 Like