无法在python中导入numpy库

时间:2017-07-05 12:59:19

标签: python python-2.7 python-3.x

我已经安装了python 3.6并通过pip添加了numpy模块,但在尝试导入库时遇到以下错误。请帮助:

>>> import numpy
Traceback (most recent call last):
  File "C:\Users\as338011\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\__init__.py", line 16, in
<module>
    from . import multiarray
ImportError: DLL load failed: The specified procedure could not be found.

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\as338011\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\__init__.py", line 142, in <mod
ule>
    from . import add_newdocs
  File "C:\Users\as338011\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\add_newdocs.py", line 13, in <m
odule>
    from numpy.lib import add_newdoc
  File "C:\Users\as338011\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\lib\__init__.py", line 8, in <m
odule>
    from .type_check import *
  File "C:\Users\as338011\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\lib\type_check.py", line 11, in
 <module>
    import numpy.core.numeric as _nx
  File "C:\Users\as338011\AppData\Local\Programs\Python\Python36\lib\site-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.

原始错误是:DLL加载失败:找不到指定的过程。

1 个答案:

答案 0 :(得分:0)

正如您的终端所示,您可能安装了不正确的numpy版本。如果您正在使用python 3,那么您将需要执行pip3 install numpy而不是使用普通(python 2.7)pip。无论哪种方式,您应该尝试重新安装numpy,或者如果仍然无效,您可以从源代码构建它。 这是基于这样一个事实,即问题似乎与numpy包有关,而不是你的系统本身。