突然,我的python文件因为ImportError而不能再运行了。我已经尝试过通过conda更新/重新安装pandas,但这并没有改变任何事情。
File "/p/tmp/user/env/lib/python3.7/site-packages/pandas/__init__.py", line 29, in <module>
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
File "/p/tmp/user/env/lib/python3.7/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
File "/p/tmp/user/env/lib/python3.7/site-packages/pandas/_libs/tslibs/__init__.py", line 30, in <module>
from .conversion import OutOfBoundsTimedelta, localize_pydatetime
File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
File "pandas/_libs/tslibs/timezones.pyx", line 7, in init pandas._libs.tslibs.timezones
ImportError: cannot import name gettz
srun: error: cs-g14c06b11: task 0: Exited with exit code 1
srun: Terminating job step 19094047.0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/p/tmp/user/file_name.py", line 3, in <module>
import pandas as pd
File "/p/tmp/user/env/lib/python3.7/site-packages/pandas/__init__.py", line 37, in <module>
) from e
ImportError: C extension: gettz not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.
我可以试着解决这个问题吗?
发布于 2021-01-08 16:17:44
根据furas的建议,安装dateutil
包修复了这个错误。
https://stackoverflow.com/questions/65609036
复制相似问题