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

3
  • 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? Commented Mar 27, 2014 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... Commented Mar 27, 2014 at 23:04
  • Maybe tring Theano development could help, but I would'nt bet on that. Commented Mar 28, 2014 at 18:40

2 Answers 2

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.

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

1 Comment

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).
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?

1 Comment

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.

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.