Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python newbie: importing numpy module in eclipse

I'm trying to run a simple python program in eclipse. This is the first time that I'm importting any module.

So I downloaded: numpy and pylab (I'm using a mac) restarted my eclipse and the red line below the

import numpy
import pylab

disappeared so I understood that the reference to that module is ok.

Problem is that I still see red line below the code and wonder why? I have to stress out that I believe numpy was already 'pre-installed' I just upgraded the version (using 1.5.1-py2.7).

Can anyone tell what should I do to run this code?

enter image description here

my interpreter setting on eclipse:

enter image description here

like image 810
adhg Avatar asked Feb 21 '23 04:02

adhg


2 Answers

If you are using PyDev, you should first have to go to Preferences, then Pydev, then Interpreter Python and then Libraries to add NumPy.

Else, verify that you have NumPy installed, from the interpreter, just call from numpy import *

Edit:

Also check you already have Matplotlib installed, the error you are getting on the console points to that being the cause, you can download Matplotlib here.

like image 159
El Developer Avatar answered Mar 06 '23 05:03

El Developer


I recently installed Anaconda3 and just started learning how to use Pandas and I wanted to be able to work with Pandas in Eclipse as well.

I first tried adding a reference to the site-libraries at:

C:\Anaconda3\Lib\site-packages

And it seemed to work by allowing me to import numpy and pandas. However, since I had just used conda to update everything, my Python34 interpreter seemed to fail when I tried running some code and numpy was looking for my Python35 installation. For some reason this was located at:

C:\Users\myname\AppData\Local\Programs\Python\Python35-32

However, Anacondas installed another version somewhere else. By going into:

Windows > Preferences > PyDev > Interpreters > Python Interpreter

and clicking on Quick Auto-Config it found my Anacondas version of Python35 and then I just had to figure out how to make my current project use the Python35 interpreter.

Hint: To do this, you need to go into the Project properties by opening the project and choosing File > Properties or right-click the project to choose Properties.

like image 36
Rick Henderson Avatar answered Mar 06 '23 05:03

Rick Henderson