Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Problem importing libraries installed with PIP in Eclipse

1,237 views
Skip to first unread message

Fabio Zadrozny

unread,
Feb 15, 2014, 1:25:15 PM2/15/14
to Renato, python list

On Fri, Feb 14, 2014 at 1:30 AM, Renato <rver...@gmail.com> wrote:
Hi guys, I'm using Python 2.7.5 64 bits and I have a problem when importing libraries that were installed via PIP when importing them inside Eclipse (version 4.3.1). Outside Eclipse (directly in Python's shell) everything works fine, here is an example:

>>> import numpy                             # installed from repositories
>>> from numpy import array
>>> import pybrain                           # installed via PIP
>>> from pybrain import Network
>>>

Everything works outside Eclipse. But inside Eclipse I can't import libraries installed via PIP using "from x import y" format, it will give an error. The only way I can import libraries installed via PIP is using "import x" format. Here is an example:

import numpy                                     # no errors (installed from repositories)
from numpy import array                          # no errors
import pybrain                                   # no errors (installed via PIP)
from pybrain import Network                      # gives the error below

Traceback (most recent call last):
  File "/media/arquivos/pybrain_import_test.py", line 4, in <module>
    from pybrain import Network
ImportError: cannot import name Network

I suspected it could be related to virtualenv, but here is a print screen (http://imageshack.com/a/img534/4307/3x0m.png) of my Python's PATH. The directory /usr/lib/python2.7/site-packages where PyBrain is installed is already in Python's PATH inside Eclipse. Could someone help me, please?
--
https://mail.python.org/mailman/listinfo/python-list

Hi Renato,

Can you do the following:

Create a new script with:

import sys
print '\n'.join(sorted(sys.path))

And let me know if the paths you have listed in both are equal... Also, which version of PyDev are you using?

Cheers,

Fabio

Fabio Zadrozny

unread,
Feb 17, 2014, 2:07:22 PM2/17/14
to Renato, python list

On Sun, Feb 16, 2014 at 11:52 AM, Renato <rver...@gmail.com> wrote:
It's solved now, oh my god I was so stupid! I created a package named "pybrain" for testing PyBrain module, so obviously when I tryed to import something from PyBrain library, Python would import all modules from this personal package I created. The problem was not being reproduced outside Eclipse because only within Eclipse my personal workstation directory (which contained the personal package "pybrain") was visible. The solution was simple: I just deleted the personal package named "pybrain" and now everything is working. Thank you very much for your help!


Hi Renato,

Nice that you got it working...

Now, just as a heads up, that version of PyDev is quite old (the latest PyDev release: 3.3.3 is in many ways improved when comparing to older PyDev versions). I know Aptana Studio still has the older version, so, if you use mostly Python and you don't need the other features that Aptana Studio adds, it might be worth going to pure Eclipse + PyDev (or using LiClipse which also adds support for other languages -- besides being better configured out of the box, although it's a commercial counterpart of PyDev -- whose funds help to keep PyDev development going forward).

Cheers,

Fabio
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages