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

有帮助吗?

解决方案

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.

其他提示

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?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top