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])
[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?
Best How To :
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:
- Install NumPy for 3.4 as well. You can do this by running
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.
- Configure PyDev to use 3.5 instead of 3.4.
- Uninstall either 3.4 or 3.5. You'll still have to do one of the above as well, but this will make it impossible to get wrong, and reduce the chances of you getting similarly confused again in the future.
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
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.