PDA

View Full Version : Problem Using Numpy with Eclipse + pydev



iamscottym
02-11-2011, 05:30 PM
I've having a problem using numpy with eclipse + pydev under Ubuntu.

I installed numpy via synaptic and then add the following line to my code.
from numpy import *
When I run that I get the following error message.
ImportError: No module named numpy

Could anyone offer insight into this problem?

jes1510
02-11-2011, 07:17 PM
It sounds like it didn't install correctly or you have a bizarre python installation. Open the software center and make sure python-numpy shows as installed.

iamscottym
02-11-2011, 07:21 PM
python was already installed with this distro of Ubuntu. Numpy appears to be installed properly. Could it be an Eclipse problem?

jes1510
02-11-2011, 07:26 PM
Possibly. Try it from the command line. Open a terminal and run the python interpreter from there:
python
>>> import numpy
if it doesn't throw an error then you are good and it's an eclipse problem.

iamscottym
02-11-2011, 07:45 PM
damn, that was so obvious i can't believe i missed that. i guess its an eclipse problem.

I pulled up preferences-interpreter-pydev-forced builtins and it shows numpy listed. hmm...

jes1510
02-11-2011, 10:02 PM
You're on your own from here on. I'm not an eclipse user. Good luck though!

Amp
02-12-2011, 01:47 AM
Hi iamscottym (http://forums.trossenrobotics.com/member.php?u=2730)

So good new defiantly possible
I have just tried it on my setup and I can get numpy to work. Using the following
from numpy import *
a = arange(10)
print a

Bad news is Im not 100% sure why mine is working and yours isnt, here's a couple of ideas.
* I created a new numpy project (could it be an issue with an old project maybe?
* I cant remember if I installed pydev before or after numpy....I think after but not sure. This might effect it.
* The only other thing I could suggest is to get eclipse to re-scan your python modules.
(preferences/pydev/Interpreter-python) then 'Autoconfig button

iamscottym
02-12-2011, 04:00 AM
Could you check whether numpy is listed in the System-Pythonpath? Go to Preferences/-Pydev/Interpreter-Python/ and Select Libraries. I don't see numpy listed and I feel like I should. Where would numpy be located after installing it with synaptic?

Amp
02-17-2011, 06:27 AM
Doing a "locate numpy" shows that numpy is under dist-packages at
/usr/lib/python2.6/dist-packages/

In eclipse numpy is not in the System-Pythonpath explicitly, I think its under one of these entrys,
lib/python2.6/dist-packages or /usr/local/lib/python2.6/dist-packages.