使用 matplotlib 时出现“No module named _multiarray_umath”
I get `No module named _multiarray_umath` when using matplotlib
当我 运行 在 CI 中进行测试时,出现以下错误:
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
这是怎么回事?我没有对我的代码进行任何更改,但是突然之间
我的构建开始失败。
解决方案
在安装 sdist 之前使用 pip 单独安装 numpy。
对于 tox,将 numpy 直接添加到您的 deps 数组。
为什么会这样?
Numpy 最近发布了 numpy-1.16.0rc2
到 pypy,这是什么(与 easy_install 中的 bug/oversight 一起)破坏了你的构建:
pip 知道默认情况下不安装 RC,但 easy_install(matplotlib 使用它来进行构建)不会。如果你用一大堆 -vvvvvv
s 做 sdist,你会看到这样的东西:
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
特别注意,matplotlib 是针对 numpy-1.16.0rc2-py2.7
构建的。但是在另一个地方你可能会看到类似
的东西
Successfully installed ... numpy-1.15.4 ...
因此,当您尝试 运行 您的程序时,matplotlib 将尝试访问非 RC 版本的 numpy 中不存在的模块,但会失败。
如果您已经安装了 numpy,easy_install 将不会尝试获取自己的版本,而是使用(正确的)现有版本。
另见
解决方法是需要升级numpy。
如果你使用 pip
pip install numpy --upgrade
希望对您有所帮助。
当我 运行 在 CI 中进行测试时,出现以下错误:
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
这是怎么回事?我没有对我的代码进行任何更改,但是突然之间 我的构建开始失败。
解决方案
在安装 sdist 之前使用 pip 单独安装 numpy。
对于 tox,将 numpy 直接添加到您的 deps 数组。
为什么会这样?
Numpy 最近发布了 numpy-1.16.0rc2
到 pypy,这是什么(与 easy_install 中的 bug/oversight 一起)破坏了你的构建:
pip 知道默认情况下不安装 RC,但 easy_install(matplotlib 使用它来进行构建)不会。如果你用一大堆 -vvvvvv
s 做 sdist,你会看到这样的东西:
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
特别注意,matplotlib 是针对 numpy-1.16.0rc2-py2.7
构建的。但是在另一个地方你可能会看到类似
Successfully installed ... numpy-1.15.4 ...
因此,当您尝试 运行 您的程序时,matplotlib 将尝试访问非 RC 版本的 numpy 中不存在的模块,但会失败。
如果您已经安装了 numpy,easy_install 将不会尝试获取自己的版本,而是使用(正确的)现有版本。
另见
解决方法是需要升级numpy。 如果你使用 pip
pip install numpy --upgrade
希望对您有所帮助。