[英]Trying to download modules but python can't find them
So I need some modules for a project and after trying a lot of things and googling a lot of things I still can't get it to work. 因此,我需要一个项目的模块,在尝试了很多事情并进行了很多事情之后,我仍然无法使它正常工作。 I used this code to test if the module was working:
我使用以下代码来测试模块是否正常工作:
import sys 导入系统
sys.path.append('c:\\users\\my name\\anaconda2\\lib\\site-packages') sys.path.append('c:\\ users \\ my name \\ anaconda2 \\ lib \\ site-packages')
import numpy 导入numpy
x = randn(100,100) x = randn(100,100)
And I got this error: 我得到了这个错误:
Traceback (most recent call last): 追溯(最近一次通话):
File "C:\\Users\\My Name\\Desktop\\test.py", line 3, in 文件“ C:\\ Users \\ My Name \\ Desktop \\ test.py”,第3行,在
import numpy
ImportError: No module named numpy ImportError:没有名为numpy的模块
Any idea why I'm doing wrong? 知道我为什么做错了吗?
You can try two things: 您可以尝试两件事:
1) which python
And see what python you are using. 并查看您正在使用什么python。 You may be still pointing to old python the system has.
您可能仍指向系统中的旧python。 In that case add ~/anaconda2/bin to $PATH environment variable.
在这种情况下,将〜/ anaconda2 / bin添加到$ PATH环境变量中。
2) sys.path.append('c:\users\my_name\anaconda2\lib\python2.x\site-packages')
Usually anaconda library is installed under lib\\pythonx.x(the correct python version number)\\site-packages. 通常,anaconda库安装在lib \\ pythonx.x(正确的python版本号)\\ site-packages下。 So change that.
所以改变它。
If none of the above worked, then just do clean install from scratch all over again. 如果上述方法均无效,则只需重新进行全新安装即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.