Reputation: 372
I'm trying to use NumPy in Eclipse, in which I'm using Python 3.4 and PyDev. I have installed NumPy version 1.9.2 (with setup.py) and it works fine in IDLE
>>>import numpy as np
>>>a = np.array([0,1,2,3])
>>>print(a)
[0 1 2 3]
but when I do the same thing in Eclipse I get an error No Module named 'numpy'
I have already gone to Preferences > PyDev > Interpreters > Python Interpreter > Libraries
and added the NumPy location /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy
and restarted my machine.
I'm at a loss for what to try next, do I need to delete and reconfigure all of PyDev in order for this to work?
Upvotes: 0
Views: 11127
Reputation: 365747
The problem is that you have a Python 3.4 installation, which you're using in PyDev, and a Python 3.5 installation, which you're using in the terminal. Each one has its own separate site-packages. So, when you installed NumPy by running its setup.py with a Python 3.5, it got installed into the 3.5 site-packages, but when you went looking for it in PyDev, it wasn't in the 3.4 site-packages.
You can see the version number 3.5 right there in the output you provided. However, if you want to be absolutely sure, you can print(sys.version)
from inside PyDev and from on the terminal.
At any rate, the solution is to do any of the following:
python3.4 setup.py install
(the same as you did for 3.5 but with python3.4
instead of just python3
). However, if pip3.4 install numpy
works, this is usually better.If you're wondering why this didn't help:
... and added the NumPy location /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy
The problem is that you added site-packages/numpy
instead of just site-packages
. There's no package named numpy
inside the numpy
package.
However, you don't want to fix things by adding the 3.5 site-packages to the 3.4 search path; many packages, especially those that require compiled C code like numpy
, won't work with a version of Python different from the one they were installed for.
Upvotes: 1
Reputation: 26
Check that Eclipse is using the correct Python interpreter with,
import sys
print(sys.version)
At the start of the program. If it returns anything other than what you've expected you've likely installed it to the wrong Python version.
Upvotes: 0