Code Sample, a copy-pastable example if possible
import pandas as pd
Problem description
This issue came up while running unit tests on our library. Specifically, this issue came from running tox on a clean Python 3.4 environment. In the requirements.txt, we did not specify any constraints on numpy or pandas.
By trial and error, I was able to resolve this issue by constraining pandas<0.21.1
.
Here is the test failure output:
ImportError while importing test module.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.tox/py34/lib/python3.4/site-packages/pandas/__init__.py:26: in <module>
from pandas._libs import (hashtable as _hashtable,
.tox/py34/lib/python3.4/site-packages/pandas/_libs/__init__.py:4: in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
pandas/_libs/tslib.pyx:1: in init pandas._libs.tslib
???
E ImportError: numpy.core.multiarray failed to import
During handling of the above exception, another exception occurred:
:9: in <module>
import pandas as pd
.tox/py34/lib/python3.4/site-packages/pandas/__init__.py:35: in <module>
"the C extensions first.".format(module))
E ImportError: C extension: numpy.core.multiarray failed to import 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.
------------------------------------------------------------------------------------------------------------------------------- Captured stderr --------------------------------------------------------------------------------------------------------------------------------
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
________________________________________________________________________________________________________________ ERROR collecting ________________________________________________________________________________________________________________
9: in <module>
import pandas as pd
.tox/py34/lib/python3.4/site-packages/pandas/__init__.py:26: in <module>
from pandas._libs import (hashtable as _hashtable,
.tox/py34/lib/python3.4/site-packages/pandas/_libs/__init__.py:4: in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime pandas/_libs/tslib.pyx:1514: in init pandas._libs.tslib ???
E AttributeError: type object 'pandas._libs.tslib._TSObject' has no attribute '__reduce_cython__'
Comment From: jreback
support for 3.4 was dropped in 0.21.0: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#whatsnew-0210-api-breaking
Comment From: TomAugspurger
Looks like newer setuptools have a python_requires
keyword, so we could add
python_requires=">=3.4"
to our setup
in setup.py
. Then pip install pandas
would get the correct version (well, 0.21 will still be there with the incorrect setup.py, but it'll be fixed going forward).