[Fixed] Invalid syntax (easy_light_color_sensor.py, line 198)

When importing easygopigo3 in python I get the error "invalid syntax (easy_light_color_sensor.py, line 198). This failure seems to be keeping me from loading the module to work with the distance sensor.

I just converted to rasbian today. I used the DI software update to update both the software and firmware on my GoPiGo3. I had not gotten this error previously when I was running DexterOS.

I tried it with both python 2.7 and python 3.5, but got the same result both times.

Anything that I could do to update the easygopigo3 module?

User here, not DI:

This is interesting, albeit frustrating you. Line 198 is using the new Python 3.6 feature called f-strings, so is preventing the import in Your environment.

You either need to update your sys to Python 3.7 or need to copy that file to your directory and comment out the two f-string uses.

All current DI OS and software is assuming Python 3.7 goin forward, (I think). Contact support@modrobotics.com for better help.

Thanks for the info! I’ll install Python 3.7 and see how it goes.

If Python 3.7 is assumed going forward, it would be nice if the boot image included it instead of Python 3.5.

1 Like

I don’t think upgrading Python on a Raspbian For Robots OS will be successful. I tried upgrading my R4R Stretch OS once and had to back it out as the system Python. Eventually I figured out how to have both 3.5 and 3.7 installed, with Python3.7 only for virtual environments.

I submitted a GitHub issue against the DI_Sensors easy_light_color_sensor.py file:

and against the addition of easy_light_color_sensor to the easygopigo3.py file:

The easiest workaround will be to copy that file to your working directory and comment out those two f-string lines, or the whole calibrate method with triple quotes.

copy /home/pi/Dexter/DI_Sensors/Python/di_sensors/easy_light_color_sensor.py   .

Since it will be in the path before the OS dist-packaged version, Python should use your safe version for the import.

Tagging @moderators

Thanks for bringing this up. It is now fixed.
The change was made for DexterOS which runs 3.7 It didn’t click that we couldn’t just bring it back into the main repo. Apologies, we definitely goofed there.


So @e.goldbloom, we can either use the “DI Software Update” shortcut on the R4R desktop, or

sudo curl -L dexterindustries.com/update_r4r | bash

command to get the new file integrated to the dist packages.

1 Like

Thanks so much for all of the help on this. I did another software update and it is working now.

You were correct that going to python 3.7 on R4R would not work. I was able to install the new version of python, but couldn’t get the packages over to it via pip.

Thanks again!