Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import Numpy in Python

Tags:

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?
like image 319
Nathan Fellman Avatar asked Aug 13 '09 16:08

Nathan Fellman


People also ask

Does Python 3.9 support numpy?

The numpy package does not yet include binaries for Python 3.9, so pip tries to compile from source. This (of course) requires you to have the appropriate C compiler, as the error message says. That is not straightforward. pip wants Visual C++ 14.2.

Does Python 3.7 support numpy?

The Python versions supported in this release are 3.8-3.10, Python 3.7 has been dropped.

Why numpy is not working in PyCharm?

However, if we use the following lines of code to import NumPy, it will throw an error. To install NumPy on PyCharm, click on File and go to the Settings. Under Settings, choose your Python project and select Python Interpreter. Then, search for the NumPy package and click Install Package.


2 Answers

Have you installed it?

On debian/ubuntu:

aptitude install python-numpy 

On 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 
like image 133
nosklo Avatar answered Oct 17 '22 18:10

nosklo


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*'

like image 20
Johannes Bittner Avatar answered Oct 17 '22 18:10

Johannes Bittner