numpy跟anaconda的兼容性问题

在anaconda中新建一个环境,然后numpy报错,numpy版本是1.15.4,网上的解决方式是卸载numpy,然后重装,无论是pip还是conda方式重装都不解决问题。在github的numpy问题中找到了解决方案,原因是conda安装的numpy有问题。


 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: DLL load failed:

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using c:\tools\Anaconda3\envs\test8\python.exe),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

Original error was: DLL load failed: The specified module could not be found.

 

问题解决方案:

 https://github.com/numpy/numpy/issues/12957

0 测试一下python -c "import numpy",有报错

(gluon) C:\Users\Administrator>python -c "import numpy"
Traceback (most recent call last):
  File "e:\ProgramData\Anaconda3\envs\gluon\lib\site-packages\numpy\core\__init_
_.py", line 16, in <module>
    from . import multiarray
ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "e:\ProgramData\Anaconda3\envs\gluon\lib\site-packages\numpy\__init__.py"
, line 142, in <module>
    from . import add_newdocs
  File "e:\ProgramData\Anaconda3\envs\gluon\lib\site-packages\numpy\add_newdocs.
py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "e:\ProgramData\Anaconda3\envs\gluon\lib\site-packages\numpy\lib\__init__
.py", line 8, in <module>
    from .type_check import *
  File "e:\ProgramData\Anaconda3\envs\gluon\lib\site-packages\numpy\lib\type_che
ck.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "e:\ProgramData\Anaconda3\envs\gluon\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.

Original error was: DLL load failed: 找不到指定的模块。


1 找到numpy的库目录,例如E:\ProgramData\Anaconda3\envs\gluon\Lib\site-packages\numpy\.libs。其中gluon是一个新建的环境。里面有个dll,我这里是libopenblas.CSRRD7HKRKC3T3YXA7VY7TAZGLSWDKW6.gfortran-win_amd64,复制一个新的,重命名为libopenblas.dll


2 在conda命令行中将上述的目录加入到PATH路径中
PATH=E:\ProgramData\Anaconda3\envs\gluon\Lib\site-packages\numpy\.libs;%PATH%

(gluon) C:\users\Administrator\Documents\ai\d2l-zh-1.0>PATH=E:\ProgramData\Anaco
nda3\envs\gluon\Lib\site-packages\numpy\.libs;%PATH%


3 测试一下python -c "import numpy",没有报错就正常了。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值