4

I just started playing around with Theano but have a strange problem in Eclipse. I am trying to import the config module to run some example code. The import works fine and I can see what's in the module.

Here is the simple code I am trying:

from theano import config
print config

This works fine and I get an output like:

floatX (('float64', 'float32')) 
  Doc:  Default floating-point precision for python casts
  Value:  float32
...

and some more lines like that. Unfortunately if I use the following code, I get an "undefined variable from import"-error for the floatX:

from theano import config
print config.floatX

This is only happening in Eclipse. In the console I get "float32", which is the correct output. Any idea why this is happening and how I can get to give me the value behind that variable? Thank you!

System: OSX 10.9.2 / Python: 2.7.6 (Macports installation) / Theano: 0.6.0 (Macports installation) / Eclipse: Kepler Service Release 2

cowhi
  • 2,165
  • 2
  • 17
  • 21
  • Strange, did you try to print theano.config.floatX? Did you try to print other configuration variable that you don't change? How do you set the float32 value to floatX? – nouiz Mar 27 '14 at 13:13
  • I tried theano.config.floatX as well with the same result. Works in console, doesn't work in eclipse. I have tried other variables defined in the config also with the same result. The floatX variable is set in a theano config file with a standard value. I also tried to set it using a personal config file ~/.theanorc and set the floatX to float32. No success in any way. The problem seems to be with the import of the config module, but I can't figure out, what... – cowhi Mar 27 '14 at 23:04
  • Maybe tring Theano development could help, but I would'nt bet on that. – nouiz Mar 28 '14 at 18:40

2 Answers2

3

ok, I found the answer finally. I never really had an error. I did not find that out because I never tried to actually run the script because the editor indicated there was an error... The maker of PyDev answered the following question himself and provides a workaround:

How do I fix PyDev "Undefined variable from import" errors?

For code in your project, the only way is adding a comment saying that you expected that (the static code-analysis only sees what you see, not runtime info -- if you opened that module yourself, you'd have no indication that main was expected).

You can use ctrl+1 (Cmd+1 for Mac) in a line with an error and pydev will present you an option to add a comment to ignore that error.

Community
  • 1
  • 1
cowhi
  • 2,165
  • 2
  • 17
  • 21
  • 2
    Actually, there is a solution better than this workaround, also reported in the question you linked. You have to go to the Python interpreter settings in Eclipse preferences and add `theano.configdefaults` to the list of built-ins (note that the actual module is called `configdefaults`; `config` is dynamically created in it). – erickrf Jul 18 '15 at 23:13
0

Is Eclipse using the same version of python as what you are running in the shell (console)? Does Eclipse know where to find theano- does it have a PYTHONPATH setting for it?

What OS are you using?

Fred Mitchell
  • 2,145
  • 2
  • 21
  • 29
  • Yes, I am using the same installation and the theano package is found and can be imported. I have no specific setting for theano in the PYTHONPATH settings, but I asume it is included in "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/". I can run the theano test without problems. The OS is a Mac OSX 10.9.2. – cowhi Mar 28 '14 at 23:55