Blinkt! colorsys wont work


#1

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?


#2

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


#3

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

import colorsys
^
SyntaxError: invalid syntax


#4

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

#5

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


#7

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


#8

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


#9

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.


#10

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.


#11

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?