importing matplotlib in eclipse

10,643

from pydev tutorial (in my experience, the two most common cases related with your problem):

1)

The most common error is having a problem in the environment variables used from the shell that spawned Eclipse, in a way that for some reason when getting the variables of one interpreter, it gathers the info from another interpreter (thus mixing the interpreter and the actual libraries).

2)

If you add something to your python installation, you need to either add it manually as a 'new folder' in the System PYTHONPATH (if it's still not under a folder in the PYTHONPATH) or (recommended) remove your interpreter and add it again, then, press apply.

Share:
10,643
sigma.z.1980
Author by

sigma.z.1980

Updated on July 26, 2022

Comments

  • sigma.z.1980
    sigma.z.1980 almost 2 years

    I'm running pydev in Ecplise (Python 2.7). Numpy and tkinter work fine, but I installed matplotlib and for some reason when I try

    from matplotlib import *

    I get the response it's not found. I added the folder with the module to PythonPath but keep getting same message. What am I doing wrong?

    • joaquin
      joaquin over 12 years
      could you give more info? linux, windows ?, do you have other pythons installed ? Do you reloaded your interpreter after installing mpl ?
    • sigma.z.1980
      sigma.z.1980 over 12 years
      Mac. I reloaded the interpreter. Strang thing with the versions though. I have idle installed that runs python 2.7 and can't import anything like numpy. I work in eclipse though that runs Python 2.6 and had no problems with numpy or tkinter, but still can't install matplotlib
    • joaquin
      joaquin over 12 years
      This could by common error #1: Two different interpreters and your library in the wrong one. Check pydev tuorial link I gave to you in my answer. You have there detailed instructions of how to configure interpreter. Again, are you in windows or linux?
    • sigma.z.1980
      sigma.z.1980 over 12 years
      no, it's MacOS. I followed the link, still nothing works. The interpreter is for python2.6. Can I add the interpreter for python2.7? Will it lead to conflict of versions?
    • joaquin
      joaquin over 12 years
      I can not help you with MacOS. Afaik there is no conflict in windows, pydev configures the libraries for the selected interpreter. Obviously you have to have all the needed libraries installed for both interpreters.
  • sigma.z.1980
    sigma.z.1980 over 12 years
    'remove the interpreter' you mean to remove all the libraries from the interpreter and add them again? BTW I added matplotlib to forced builtins but still get the 'cant find the module' message
  • joaquin
    joaquin over 12 years
    When you reload your interpreter pydev scans again all the libraries automatically. Do not get wrong, this doesnt refers to python reload but to deleting and adding again your interpreter in pydev interpreter configuration dialog. Please check tutorial
  • sigma.z.1980
    sigma.z.1980 over 12 years
    Ok thanks it actually worked. I don't know what I did wrong before, it certainly didn't do the trick
  • Diego Herranz
    Diego Herranz over 10 years
    2 option made it. Thanks!