Blinkt! colorsys wont work

I just got my pi zero w and im trying out the example codes from https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-blinkt, but whenever i try to do the rainbow one i get an error message saying SyntaxError: invalid syntax… Anyone got any tips?

Can you please post the full error please so we can help you debug the problem further

1 Like

Yes i can :)
File “ok.py”, line 1

import colorsys
^
SyntaxError: invalid syntax

do you have a shebang in that file? if not you need to explicitly run it as an argument to python, like so:

python ok.py

Im still quite new to programming, so im not sure what shebang is, but ive tried to run it as sudo python ok.py and python ok.py

hum, do you have a file named colorsys.py in that same directory by any chance? if so, that is the problem.

Nope…I have the file saved in /home/pi…

please start python in interactive mode, i.e type just ‘python’ at the command prompt.

then, in the interpreter, type:

import colorsys

if you don’t get the same error - and you shouldn’t - then the issue has to do with the context related to the file you have created, or the editor you are using to create it. Ultimately if you don’t share those details it will be difficult to make any progress with your issue.

Thanks for the tips. Its seems to work whenever i make the program in the terminal, but not when i make it in the IDE.

do you mean the idle program? seems to work pasting the code and running it (F5) here… can you talk us through the steps you follow?