3

When I try to import numpy on Python, it says:

ImportError: No module named numpy

If I try to install numpy, it says it has already been installed. It seems like it's been installed, but in a wrong place? I don't know where it should be though.

Python version is 2.4.6, but if I try to install a newer version, like 2.7, it says it has already been installed.

tshepang
  • 12,111
  • 21
  • 91
  • 136
user3443649
  • 31
  • 1
  • 2

1 Answers1

3

You can ask Python if numpy is installed, by searching through sys.path:

>>> import os
>>> import sys
>>> for p in sys.path:
...  if os.path.exists(os.path.join(p, 'numpy')):
...   print p
...   break
... else:
...  print "Numpy not found"
/usr/lib/python2.7/dist-packages

In this case, I have numpy installed in /usr/lib/python2.7/dist-packages. "Numpy not found" will be printed if it's not installed.

If you're on Windows (sounds like maybe?) then you need to make sure that the path is set up correctly. It sounds like you may have more than one python installed, and numpy is being installed in one of them, but your default interpreter is the other one.

Seth
  • 45,033
  • 10
  • 85
  • 120