I get `No module named _multiarray_umath` when using matplotlib

Solution

Install numpy using pip seperately, before installing your sdist.

For tox, add numpy directly to your deps array.

Why did this happen?

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 -vvvvvvs, 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.

See also

  • http://numpy-discussion.10968.n7.nabble.com/Issue-with-setup-requires-and-1-16-release-candidates-td46600.html