Hi @eirannejad,
any news on this topic? Will this be fixed in the future?
I updated to Rhino 8 SR 14 (8.14.24325.13001, 2024-11-20) and played around with the pandas import once again. The pandas import works fine within the powershell of Rhino CPython (C:\Users\user_xy\.rhinocode\py39-rh8\python
). Below I summarized my observations using pandas 2.1.1 inside the ScriptEditor:
I can use
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
in any python 3 script and execute it once. Afterwards, I can use import pandas
in any other script and it works just fine. I do not have to add the C:\Users\user_xy\.rhinocode\py39-rh8\Scripts
path to the module search path. Even, if I execute the reload of Python 3, I do not have to add the two locale
script lines anymore.
If I forget about executing the two locale
script lines prior to import pandas
at the beginning of my Rhino python session, I receive the following error:
Traceback (most recent call last):
File "file:///C:/Users/user_xy/.rhinocode/stage/tgrjxfwu.j2y", line 5, in <module>
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\pandas\__init__.py", line 73, in <module>
from pandas.core.api import (
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\pandas\core\api.py", line 1, in <module>
from pandas._libs import (
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\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 1, in init pandas._libs.missing
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\pandas\_libs\tslibs\__init__.py", line 39, in <module>
from pandas._libs.tslibs.conversion import localize_pydatetime
File "conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
File "offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
File "timestamps.pyx", line 1, in init pandas._libs.tslibs.timestamps
File "timedeltas.pyx", line 86, in init pandas._libs.tslibs.timedeltas
File "fields.pyx", line 7, in init pandas._libs.tslibs.fields
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\_strptime.py", line 268, in <module>
_TimeRE_cache = TimeRE()
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\_strptime.py", line 182, in __init__
self.locale_time = LocaleTime()
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\_strptime.py", line 69, in __init__
self.lang = _getlang()
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\_strptime.py", line 28, in _getlang
return locale.getlocale(locale.LC_TIME)
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\locale.py", line 593, in getlocale
return _parse_localename(localename)
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\locale.py", line 501, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: en-US
Afterwards, executing the following lines
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
import pandas
raises the following exception:
Traceback (most recent call last):
File "file:///C:/Users/user_xy/.rhinocode/stage/tgrjxfwu.j2y", line 5, in <module>
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\pandas\__init__.py", line 73, in <module>
from pandas.core.api import (
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\pandas\core\api.py", line 1, in <module>
from pandas._libs import (
File "C:\Users\user_xy\.rhinocode\py39-rh8\lib\site-packages\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)
Reloading the python 3 engine does not help at that state. It only works again, if I restart Rhino 8 and first execute the two âlocaleâ script lines.