Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » [SOLVED] Error importing Python's PyBrain library in Eclipse when using "from x import y" (The error only occurs with PyBrain library and specifically with "from x import y" format. If I use "import x" format, it works. This behavior happens only inside Eclipse.)
[SOLVED] Error importing Python's PyBrain library in Eclipse when using "from x import y" [message #1244726] Wed, 12 February 2014 20:06 Go to next message
Renato V is currently offline Renato VFriend
Messages: 8
Registered: February 2014
Junior Member
I'm using Python 2.7.5 and Eclipse 4.3.1 in OpenSUSE 13.1. I installed all my Python Libraries (ex: matplotlib, numpy, scipy etc) from OpenSUSE official repositories, except PyBrain 0.3, which I installed via PIP. Within Eclipse, specifically with PyBrain library (which, again, I installed via PIP) I can import it olny using the import format. If I try to import something from PyBrain library using from / import format, I receive an ImportError. This problem happens only with PyBrain library, which I installed via PIP, and only inside Eclipse (in Python's Shell both import formats work with PyBrain). All other libraries can import modules either using import command or from / import format inside and outside Eclipse. Here are some examples of import command and from / import command that work within Eclipse:

import matplotlib
from matplotlib import pylab
import pybrain


But I can't import nothing from PyBrain using the from / import format. The followin code:

from pybrain.supervised.trainers import BackpropTrainer


returns:

Traceback (most recent call last):
  File "/media/arquivos/pybrain_import_test.py", line 9, in <module>
    from pybrain.supervised.trainers import BackpropTrainer
ImportError: No module named supervised.trainers


Another example when trying to import a feature from PyBrain library using from / import format :

from pybrain.datasets import SupervisedDataSet


returns:

Traceback (most recent call last):
  File "/media/arquivos/pybrain_import_test2.py", line 7, in <module>
    from pybrain.datasets import SupervisedDataSet
ImportError: No module named datasets


And another one:

from pybrain import Network


returns:

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


It's strange because this error with from / import command when importing Pybrain library occurs only from within Eclipse. f I use Python shell (or IPython), the above imports work:

$ python
Python 2.7.5 (default, May 30 2013, 16:55:57) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybrain
>>> from pybrain.supervised.trainers import BackpropTrainer
>>> from pybrain.datasets import SupervisedDataSet
>>> from pybrain import Network
>>> 


So I guess the problems is related to some Eclipse setting, maybe related to some PATH. Could someone help me, please?

[Updated on: Tue, 18 February 2014 11:17]

Report message to a moderator

Re: Error importing Python's PyBrain library in Eclipse when using "from x import y" forma [message #1245029 is a reply to message #1244726] Thu, 13 February 2014 07:26 Go to previous messageGo to next message
Renato V is currently offline Renato VFriend
Messages: 8
Registered: February 2014
Junior Member
I've done a lot of readings and some people seem to suggest this problem is related to virtualenv. Does someone have a clue?
Re: Error importing Python's PyBrain library in Eclipse when using "from x import y" forma [message #1248898 is a reply to message #1245029] Mon, 17 February 2014 19:32 Go to previous messageGo to next message
Renato V is currently offline Renato VFriend
Messages: 8
Registered: February 2014
Junior Member
It's solved now! 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.
Re: Error importing Python's PyBrain library in Eclipse when using "from x import y" forma [message #1248899 is a reply to message #1245029] Mon, 17 February 2014 19:32 Go to previous message
Renato V is currently offline Renato VFriend
Messages: 8
Registered: February 2014
Junior Member
By the way, Eclipse support is very bad. I was lucky that I didn't need any support all these years and I hope I won't ever need it again, because I'll probably be on my own.


[Updated on: Mon, 17 February 2014 19:34]

Report message to a moderator

Previous Topic:EGL RUI Handler Resourcebundle
Next Topic:Cannot find companion file [Error]
Goto Forum:
  


Current Time: Sat Apr 20 04:32:28 GMT 2024

Powered by FUDForum. Page generated in 0.08273 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top