[英]Can't import Numpy in Python
I'm trying to write some code that uses Numpy. 我正在尝试编写一些使用Numpy的代码。 However, I can't import it:
但是,我无法导入它:
Python 2.6.2 (r262, May 15 2009, 10:22:27)
[GCC 3.4.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
I tried the suggestions in this question : 我尝试了这个问题中的建议:
>>> import sys
>>> print sys.path
['', '/usr/intel/pkgs/python/2.6.2/lib/python26.zip', '/usr/intel/pkgs/python/2.6.2/lib/python2.6', '/usr/intel/pkgs/python/2.6.2/lib/python2.6/plat-linux2', '/usr/intel/pkgs/python/2.6.2/lib/python2.6/lib-tk', '/usr/intel/pkgs/python/2.6.2/lib/python2.6/lib-old', '/usr/intel/pkgs/python/2.6.2/lib/python2.6/lib-dynload', '/usr/intel/pkgs/python/2.6.2/lib/python2.6/site-packages']
and I searched for files named numpy
in that path: 我在该路径中搜索名为
numpy
文件:
$ find /usr/intel/pkgs/python/2.6.2/bin/python -iname numpy\*
But nothing came up. 但没有出现。
So... 所以...
Have you installed it? 你安装好了吗?
On debian/ubuntu: 在debian / ubuntu上:
aptitude install python-numpy
On windows: 在Windows上:
http://sourceforge.net/projects/numpy/files/NumPy/
On other systems: 在其他系统上:
http://sourceforge.net/projects/numpy/files/NumPy/
$ tar xfz numpy-n.m.tar.gz
$ cd numpy-n.m
$ python setup.py install
Your sys.path is kind of unusual, as each entry is prefixed with /usr/intel. 您的sys.path有点不寻常,因为每个条目都以/ usr / intel为前缀。 I guess numpy is installed in the usual non-prefixed place, eg it.
我想numpy安装在通常的非前缀位置,例如它。 /usr/share/pyshared/numpy on my Ubuntu system.
/ usr / share / pyshared / numpy在我的Ubuntu系统上。
Try find / -iname '*numpy*'
试试
find / -iname '*numpy*'
要在Debian / Ubuntu上安装它:
sudo apt-get install python-numpy
以下命令对我有用:
python.exe -m pip install numpy
在VS上禁用pyright对我来说非常合适。
I was trying to import numpy in python 3.2.1 on windows 7. 我试图在Windows 7上的python 3.2.1中导入numpy。
Followed suggestions in above answer for numpy-1.6.1.zip as below after unzipping it 在解压缩之后,如下numpy-1.6.1.zip的回答中的建议如下
cd numpy-1.6
python setup.py install
but got an error with a statement as below 但是如下所述的声明出错了
unable to find vcvarsall.bat
For this error I found a related question here which suggested installing mingW. 对于这个错误,我在这里找到了一个相关的问题,建议安装mingW。 MingW was taking some time to install.
MingW需要一些时间来安装。
In the meanwhile tried to install numpy 1.6 again using the direct windows installer available at this link the file name is "numpy-1.6.1-win32-superpack-python3.2.exe" 同时尝试使用此链接提供的直接Windows安装程序再次安装numpy 1.6,文件名为“numpy-1.6.1-win32-superpack-python3.2.exe”
Installation went smoothly and now I am able to import numpy without using mingW. 安装进行顺利,现在我可以在不使用mingW的情况下导入numpy。
Long story short try using windows installer for numpy, if one is available. 长话短说试试使用Windows安装程序numpy,如果有的话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.