Steve2056726
Steve2056726

Reputation: 467

Problems setting up Python

I recently installed python 3.3.2 Im trying to install NumPy, when I call import NumPy from the command line I get the following error:

import numpy
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named 'numpy'

From what I've read it may have to do with having multiple version of Python installed. The only problem is when I try run the Which Python command I get another error?

which python
  File "<console>", line 1
    which python
               ^
SyntaxError: invalid syntax

Any Ideas?

Thanks

Upvotes: 0

Views: 153

Answers (2)

Stephan
Stephan

Reputation: 18001

Type open a command prompt and type python It will then tell you what version you are running as it opens the interactive python editor.

Otherwise get your numpy from here These are compiled binaries and should be the most straightforward to install for a windows user

Upvotes: 1

Roland Smith
Roland Smith

Reputation: 43533

What you have to do depends on the operating system you are using. I'me assuming you are using Linux. If you are using Linux with some kind of package manager, you should use a numpy package that is expressly for the python version you want to us it with. The same goes if you are using windows.

Note that you can have different versions of python installed, but in general only one is symlinked to python. Running ls -l /usr/local/bin/python should tell you what is the default version on your machine. If you have multiple versions, there should also be programs named python2 and python3. Using ls -l /usr/local/bin/python2 and ls -l /usr/local/bin/python3 will show you the which versions you really have.

On linux and other UNIX-like systems, you can usually find Python's files in a subdirectory of /usr/local/lib. For python 2.7 this will be /usr/local/lib/python2.7, for 3.2 it will be /usr/local/lib/python3.3. These directories will have a subdirectory site-packages. In those site-packages you should look for a subdirectory numpy. If you find /usr/local/lib/python2.7/site-packages/numpy but not /usr/local/lib/python3.3/site-packages/numpy, then numpy was not installed for 3.2.

Edit: In Windows, Python usually installs itself in the root of the C: drive, like C:\Python27 or C:\Python33. I don't have a windows machine handy, but there should be a site-packages subdirectory in both of them as well. Look for the numpy subdirectory in there.

For windows, you can find precompiled binaries for mumpy here. You just need to know is you have a 32 bit (win32) or 64 bit version (amd64) of windows. E.g. for python 3.3 and 2 32-bit windows I would suggest numpy-MKL-1.7.1.win32-py3.3.‌exe.

Upvotes: 1

Related Questions