I have several scripts that use the pandas module that have been working fine in Rhino 8 thus far. I recently updated to 8.31.26126.13431 and started getting the locale error for “en-US”. I applied the fix as described in previous posts but am now getting a new error. My import snippet and error are here:
# r: pandas, numpy, openpyxl
import os
from inspect import getsourcefile
from os.path import abspath
import datetime
import scriptcontext
import rhinoscriptsyntax as rs
import locale
locale.setlocale(locale.LC_ALL,'en_US.UTF-8')
import pandas as pd
import numpy
AttributeError: partially initialized module 'pandas' has no attribute '_pandas_datetime_CAPI' (most likely due to a circular import)
The fix in Ehsan’s fix_locale.py module, posted in the thread (Error in Rhino 8 SR31 when using pandas: unknown locale: en-US [7:1], post #18). It both corrects the BCP-47→POSIX name and overrides locale.getlocale so it won’t throw. Put it on the Python search path and import it before pandas:
python
import fix_locale
import pandas
Note: an important detail is that just adding the setlocale line to their already-crashed session won’t help — pandas is cached broken. They need to reset the Python runtime (or restart Rhino) and ensure the locale is fixed before the very first pandas import, ideally via fix_locale.py or a ScriptEditor startup command.