Skip to content
Advertisement

ImportError while importing pandas: gettz not built

Suddenly my python file won’t run anymore due to an ImportError. I already tried updating/reinstalling pandas via conda but this didn’t change anything.

  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.

What could I try to fix this?

Advertisement

Answer

As suggested by furas, installing the package dateutil fixed the error.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement