These are chat archives for spyder-ide/public

29th
Aug 2018
hofingermarkus
@hofingermarkus
Aug 29 2018 10:52

Hi guys!
I do have a really strange error that only occurs when I have code running inside spyders ipython console but NOT if i run it directly with python or ipyhton.
From the error message it looks as if the dot ".'" inside some number strings has been converted to a comma ",".
The error appears deep down in some tensorflow code, at a location where they run "exec" on some string commands.
However, inside the spyders ipython console this string cmd seems to be wrongly created, compared to a standard python or ipyhton shell...

I have seen this issue with tensorflow 1.9 and 1.10 and spyder 3.3.1

The following 3 lines will reproduce the error (although make nothing really useful):
----------------test.py------------------------
import tensorflow as tf
dataset = tf.data.Dataset.from_tensor_slices([ ["a","b","c","e"]])
dataset = dataset.apply(tf.contrib.data.assert_element_shape( tf.TensorShape(4) ) )


When run as "pyhton test.py" or "ipython test.py" it finishes without error....
But in spyder it crashes with the following error message:
def single_image_random_dot_stereograms(depth_values, hidden_surface_removal=True, convergence_dots_size=8, dots_per_inch=72, eye_separation=2,5, mu=0,333299994, normalize=True, normalize_max=-100, normalize_min=100, border_level=0, number_colors=256, output_image_shape=[1024, 768, 1], output_data_window=[1022, 757], name=None):

SyntaxError: invalid syntax

Do you have any idea where I can start searching? Shall i open up a ticket?

hofingermarkus
@hofingermarkus
Aug 29 2018 15:01
(Btw. python, ipython and spyder truly come from the same anaconda environment, double checked with "which python"...)
CAM Gerlach
@CAM-Gerlach
Aug 29 2018 15:46
@hofingermarkus Did you double check what the def single_image line looked like inside TensorFlow's actual code base? @ccordoba12 , any thoughts?
Carlos Cordoba
@ccordoba12
Aug 29 2018 15:49
Maybe Tensorflow needs some environment variables to run or initialize it correctly
CAM Gerlach
@CAM-Gerlach
Aug 29 2018 15:57
@ccordoba12 I'm not sure that could have to do with the decimal point in floats getting replaced with a comma somehow?
The actual python function is setup with parameters on line 26-56 of this file
You can see in this case the floats are passed as floats initially, since e.g. .3333 is displayed above as 0,333299994
CAM Gerlach
@CAM-Gerlach
Aug 29 2018 16:04
It then calls this higher-level function to load it as Python; nothing obvious going on at that level...
CAM Gerlach
@CAM-Gerlach
Aug 29 2018 16:10
And finally we're back to Python, where the actual parsing magic happens and almost certainly where things are going wrong; the problem is caught in the exec on line 73, but may also have something to do with the functions on lines 56-61 or the lines immediately before the exec call that results in the problem down the line.
Here's a full traceback I found on SO by Googling.
@hofingermarkus You can track down exactly where this is happening if you run the debugger with a breakpoint set on the final line of your code, then go one step past the C and track exactly how the float attributes are being represented and where the problem is inserted (if its immediately after the C code, in one of the lines before the exec call or the exec call itself). If its not clear, you could do the same with the code running in a non-Spyder qtconsole and compare the two to see where a meaningful difference is introduced (that would also rule out anything caused by something in qtconsole or its stack).
hofingermarkus
@hofingermarkus
Aug 29 2018 17:42
@CAM-Gerlach Thank you for your quick and thorough analysis!
I did already step into with the debugger but I wasn't able to step into line 61 " wrappers = py_tf.GetPythonWrappers(op_list_str)" that actually produces the string that exec() isn't able to process. At this position the string already arrives with the 0,333 instead of 0.333
Thats where I got stuck.
I've seen similar errors in other programming environments (not python), when locale settings were set to German instead of English (there a comma would actually be correct). So I was wondering if something like this could happen once spyder starts up - since this only happens inside a spyder environment and not in the regular python shell..
I'll continue with debugging it tomorrow, I need to go now. But thank you guys for your help :)