4

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

3
  • When you run that code, what happens? Commented Mar 11, 2012 at 18:26
  • RuntimeError: module compiled against API version 6 but this version of numpy is 4 Traceback (most recent call last): File "/Users/adhg/Documents/workspace/PyTest/com/csv/QPloter.py", line 13, in <module> import pylab File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pylab.py", line 1, in <module> from matplotlib.pylab import * Commented Mar 11, 2012 at 22:54
  • This error points to matplotlib being the problem, there is a link in my answer. Commented Mar 11, 2012 at 23:43

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

4 Comments

not sure, but I added the python interpreter screenshot in my eclipse. When I write from numpy import * there is no red line below the code --does it mean I can import it? thanks again!
Yep, that means you can import it.
RuntimeError: module compiled against API version 6 but this version of numpy is 4
NumPy works in the Python shell but not in Eclipse... any ideas why not?
2

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.

Comments

1

Simply removed the old numpy and installed version 6. located here

Another way to circumvent this problem is to use pip install numpy check how to install pip

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.