0

So i am trying to run a simple blink code on Raspberry Pi pico using VsCode and PicoGo extension when i run it i get ModuleNotFoundError: No module named 'machine' though when i run the same code in thonny it works just fine

from machine import Pin
from time import sleep

pin = Pin(25,Pin.OUT)

while True:
    pin.toggle()
    sleep(0.5) 

when i run this i get ModuleNotFoundError: No module named 'machine'

here's a picture to clear things up image

VLAD 05
  • 5
  • 2
  • please, no pictures of text ... copy the code listing and add to the question ... copy all of error message and add to the question – jsotola Aug 04 '22 at 18:31
  • i don't think the problem is from the code because it works fine in thonny – VLAD 05 Aug 04 '22 at 18:37
  • It sounds as if vscode may be trying to run your code using your system python rather than running it in micropython on the pico. – larsks Aug 04 '22 at 18:43
  • how can i make it run in micropython? @larsks – VLAD 05 Aug 04 '22 at 19:20

1 Answers1

1

If you try using the VS Code "Run and Debug" button...

enter image description here

...this will try running your code with the python interpreter on your host. In order to run your code on the Pico, you need to use the "Run" button in the PicoGo control bar at the bottom of the window:

enter image description here

This will send the code to the Pico and execute it there.

larsks
  • 277,717
  • 41
  • 399
  • 399