Skip to content

ImportError (import pandas) #23798

Closed
Closed
@Alexander-Shukaev

Description

@Alexander-Shukaev

Problem description

First of all, for some reason pandas==0.23.4 does not even build when installed via pip (pip install pandas==0.23.4 --force --no-cache), it simply reports success but importing pandas fails in the same way as posted below.

Not building upon installation looked weird to me (no idea if it's a bug or intentional change) but I decided to give downgrade a go:

(.venv) pip install pandas==0.23.0 --force --no-cache
Collecting pandas==0.23.0
  Downloading https://files.pythonhosted.org/packages/45/12/1e1ba99fb65df9f7f3724d3232feef35cc044d18604d57492d561e90219f/pandas-0.23.0.tar.gz (13.1MB)
    100% |████████████████████████████████| 13.1MB 1.7MB/s 
Collecting python-dateutil>=2.5.0 (from pandas==0.23.0)
  Downloading https://files.pythonhosted.org/packages/74/68/d87d9b36af36f44254a8d512cbfc48369103a3b9e474be9bdfe536abfc45/python_dateutil-2.7.5-py2.py3-none-any.whl (225kB)
    100% |████████████████████████████████| 235kB 1.6MB/s 
Collecting pytz>=2011k (from pandas==0.23.0)
  Downloading https://files.pythonhosted.org/packages/f8/0e/2365ddc010afb3d79147f1dd544e5ee24bf4ece58ab99b16fbb465ce6dc0/pytz-2018.7-py2.py3-none-any.whl (506kB)
    100% |████████████████████████████████| 512kB 1.3MB/s 
Collecting numpy>=1.9.0 (from pandas==0.23.0)
  Downloading https://files.pythonhosted.org/packages/38/39/f73e104d44f19a6203e786d5204532e214443ea2954917b27f3229e7639b/numpy-1.15.4-cp37-cp37m-manylinux1_x86_64.whl (13.8MB)
    100% |████████████████████████████████| 13.9MB 1.5MB/s 
Collecting six>=1.5 (from python-dateutil>=2.5.0->pandas==0.23.0)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, pytz, numpy, pandas
  Found existing installation: six 1.11.0
    Uninstalling six-1.11.0:
      Successfully uninstalled six-1.11.0
  Found existing installation: python-dateutil 2.7.5
    Uninstalling python-dateutil-2.7.5:
      Successfully uninstalled python-dateutil-2.7.5
  Found existing installation: pytz 2018.7
    Uninstalling pytz-2018.7:
      Successfully uninstalled pytz-2018.7
  Found existing installation: numpy 1.15.4
    Uninstalling numpy-1.15.4:
      Successfully uninstalled numpy-1.15.4
  Found existing installation: pandas 0.23.0
    Uninstalling pandas-0.23.0:
      Successfully uninstalled pandas-0.23.0
  Running setup.py install for pandas ... done
Successfully installed numpy-1.15.4 pandas-0.23.0 python-dateutil-2.7.5 pytz-2018.7 six-1.11.0

This indeed built as it should have but importing still reports errors (same as for unbuilt 0.23.4):

.venv/lib/python3.7/site-packages/pandas/__init__.py:26: in <module>
    from pandas._libs import (hashtable as _hashtable,
.venv/lib/python3.7/site-packages/pandas/_libs/__init__.py:4: in <module>
    from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
pandas/_libs/tslibs/conversion.pxd:11: in init pandas._libs.tslib
    ???
pandas/_libs/tslibs/conversion.pyx:1: in init pandas._libs.tslibs.conversion
    ???
pandas/_libs/tslibs/nattype.pyx:14: in init pandas._libs.tslibs.nattype
    ???
E   ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
ImportError while importing test module '<...>'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.venv/lib/python3.7/site-packages/pandas/__init__.py:26: in <module>
    from pandas._libs import (hashtable as _hashtable,
.venv/lib/python3.7/site-packages/pandas/_libs/__init__.py:4: in <module>
    from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
E   ImportError: cannot import name 'iNaT' from 'pandas._libs.tslib' (unknown location)

During handling of the above exception, another exception occurred:
.venv/lib/python3.7/site-packages/_pytest/python.py:481: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
.venv/lib/python3.7/site-packages/py/_path/local.py:668: in pyimport
    __import__(modname)
.venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:296: in load_module
    six.exec_(co, mod.__dict__)
.venv/lib/python3.7/site-packages/pandas/__init__.py:35: in <module>
    "the C extensions first.".format(module))
E   ImportError: C extension: 'iNaT' from 'pandas._libs.tslib' (unknown location) not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.

Any ideas how to go about it?

P.S. Please, no conda solutions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions