python 2.7.12的Numpy错误

时间:2018-05-07 10:25:22

标签: python-2.7 numpy importerror

我在Ubuntu 16.04上安装了python2.7和python3.5。在python2.7环境中编写import numpy之后,我收到以下错误,

Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: cannot import name multiarray

但是使用python3我没有遇到numpy这样的问题。如果有人遇到类似的问题,请提出解决方案。

1 个答案:

答案 0 :(得分:0)

您正在导入适用于python 3.5的Numpy版本

您必须下载适用于2.7的版本 你可以找到numpy的下载包:http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy