When I run my tests in CI, I get the following error:
ImportError while importing test module '/home/tests/test_process.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
...
.tox/py27/lib/python2.7/site-packages/matplotlib/pyplot.py:31: in <module>
import matplotlib.colorbar
.tox/py27/lib/python2.7/site-packages/matplotlib/colorbar.py:36: in <module>
import matplotlib.contour as contour
.tox/py27/lib/python2.7/site-packages/matplotlib/contour.py:14: in <module>
import matplotlib._contour as _contour
E ImportError: numpy.core.multiarray failed to import
----- Captured stderr -----
ImportError: No module named _multiarray_umath
What's going on here? I haven't made any changes to my code, but all the sudden my build started failing.
Install numpy using pip seperately, before installing your sdist.
For tox, add numpy directly to your deps array.
Numpy recently published numpy-1.16.0rc2
to pypy, which is what (in conjunction with a bug/oversight in easy_install) broke your build:
pip knows not to install RCs by default, but easy_install (which matplotlib uses to do their builds) does not. If you were to do sdist with a whole bunch of -vvvvvv
s, you'd see something like this:
gcc ... -I/tmp/pip-install-Eh8d9d/matplotlib/.eggs/numpy-1.16.0rc2-py2.7-linux-x86_64.egg/numpy/core/include ... -o build/temp.linux-x86_64-2.7/src/_contour.o
In particular, note that matplotlib is being built against numpy-1.16.0rc2-py2.7
. But then in another place you might see something like
Successfully installed ... numpy-1.15.4 ...
So then when you try and run your program, matplotlib will try to access modules that don't exist in the non-RC version of numpy, and fail.
If you already have numpy installed, easy_install won't try and fetch its own version, and will instead use the (correct) existing version.
The solution is that you need to upgrade numpy. If you are using pip
pip install numpy --upgrade
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With