python安装失败找不到指定路径,numpy已与Anaconda一起安装,但出现ImportError(DLL加载失败:找不到指定的模块)...

I am using the Anaconda distribution with Python 3.7. Among the packages installed, I have numpy, pandas, etc.

In PyCharm IDE, I have set the Project Interpreter to be the path to the python.exe installed with Anaconda:

C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\python.exe

However, when I try running a simple python script:

import numpy as np

print(np.pi)

I get an error:

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: The specified module could not be found.

See the full error message below:

Traceback (most recent call last):

File "C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core__init__.py", line 16, in

from . import multiarray

ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:/Users/my_user_name/Documents/TestMyApps/simpletest.py", line 1, in

import numpy as np

File "C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy__init__.py", line 142, in

from . import add_newdocs

File "C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in

from numpy.lib import add_newdoc

File "C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib__init__.py", line 8, in

from .type_check import *

File "C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in

import numpy.core.numeric as _nx

File "C:\Users\my_user_name\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core__init__.py", line 26, in

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: The specified module could not be found.

Process finished with exit code 1

I have tried uninstalling and reinstalling numpy using Anaconda Prompt with:

conda uninstall numpy, and then: conda install numpy [I now have numpy 1.15.4].

The re-install seem 'successful' (at least according to Anaconda Prompt), but, I keep getting an error in PyCharm.

The strange part, is when I directly go into Anaconda Prompt, and type:

python

import numpy as np

print(np.pi)

I do not get any error, and I am able to see the correct result printed out.

At first, I thought that perhaps, when using PyCharm, I am somehow pointing to a different executable, but I checked in both Anaconda Prompt and Python Console of Pycharm, using:

sys.executable

and they both show the same path:

'C:\\Users\\my_user_name\\AppData\\Local\\Continuum\\anaconda3\\python.exe'

Note that in PyCharm, when I try running a script where I am not importing any library, or when the library imported are just like sys or os, the scripts run fine. However, when I try running any other script that involves importing a library that somehow depends on numpy, it fails as well (i.e. scripts where I import pandas, etc.)

Those same scripts work fine in Anaconda Prompt.

I am at a loss here, any help would be very appreciated!

解决方案

I have actually figured out the solution. I had initially edited my System Environment Variable ‘PATH’ by adding the path to the Scripts folder in my Python executable directory.

Turns out, this was NOT enough...

I had to add more paths to it, and that magically did the trick.

See below the paths I added for the System Environment Variable PATH:

C:\Users\\AppData\Local\Continuum\Anaconda3\Scripts\

C:\Users\\AppData\Local\Continuum\Anaconda3\Library\

C:\Users\\AppData\Local\Continuum\Anaconda3\Library\bin\

C:\Users\\AppData\Local\Continuum\Anaconda3\Library\mingw-w64\bin\

Now, I am not sure exactly which one path among these 4 my System was really looking for in particular. However, adding this combination sure did work for me 😊

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值