After loading micropython on my raspberry pi pico and trying to run a simple blink code on thonny or vs code i get the same error which is the following.
>>> import machine
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "<string>", line 1, in <module>
File "/lib/machine/__init__.py", line 747
SyntaxError: invalid syntax
And here is the blink code that i tried to run.
from machine import Pin
from utime import sleep
pin = Pin("LED", Pin.OUT)
print("LED starts flashing...")
while True:
try:
pin.toggle()
sleep(1) # sleep 1sec
except KeyboardInterrupt:
break
pin.off()
print("Finished.")
When i run a print("hello") on the pico it does work. I have tried loading earlier builds of micro python but it does the same thing.
I tried to run a simple blink program to confirm that my ide and raspberry pi pico was set up correctly.It sucsessfully imports other modules like time but the moment i try to import the machine module it gives a syntax error in the init.py file.
/lib/machine/__init__.py
. It is not a problem in the code you have shown (except maybe that you shouldn't have imported that module).