[python] Can't import Numpy in Python

I'm trying to write some code that uses 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:

$ find /usr/intel/pkgs/python/2.6.2/bin/python -iname numpy\*

But nothing came up.

So...

  • Are there any other places in which Python modules are commonly installed?
  • How can I install numpy locally in my account, if it turns out that it isn't installed in the central areas?

This question is related to python import numpy

The answer is


The following command worked for me:

python.exe -m pip install numpy

Disabling pyright worked perfectly for me on VS.


To install it on Debian/Ubuntu:

sudo apt-get install python-numpy

Your sys.path is kind of unusual, as each entry is prefixed with /usr/intel. I guess numpy is installed in the usual non-prefixed place, e.g. it. /usr/share/pyshared/numpy on my Ubuntu system.

Try find / -iname '*numpy*'


I was trying to import numpy in python 3.2.1 on windows 7.

Followed suggestions in above answer for numpy-1.6.1.zip as below after unzipping it

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 was taking some time to install.

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"

Installation went smoothly and now I am able to import numpy without using mingW.

Long story short try using windows installer for numpy, if one is available.


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to import

Import functions from another js file. Javascript The difference between "require(x)" and "import x" pytest cannot import module while python can How to import an Excel file into SQL Server? When should I use curly braces for ES6 import? How to import a JSON file in ECMAScript 6? Python: Importing urllib.quote importing external ".txt" file in python beyond top level package error in relative import Reading tab-delimited file with Pandas - works on Windows, but not on Mac

Examples related to numpy

Unable to allocate array with shape and data type How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function? Numpy, multiply array with scalar TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'" Pytorch tensor to numpy array Numpy Resize/Rescale Image what does numpy ndarray shape do? How to round a numpy array? numpy array TypeError: only integer scalar arrays can be converted to a scalar index