Module 'machine' not found in Pico-W-Go/VS Code #11364
Replies: 7 comments 4 replies
-
According to https://forums.raspberrypi.com/viewtopic.php?t=35100 ,
So you SHOULD be able (in theory) to do this... Gregwa |
Beta Was this translation helpful? Give feedback.
-
Thanks Gregwa,
I tried that and got the same error. Is it possible that the micropython I
installed while installing Thonny is different from a micropython I might
have installed if I'd started with VS Code?
Thanks,
Nick
…On Fri, May 5, 2023 at 6:03 PM Gregory D Walters ***@***.***> wrote:
According to <https://forums.raspberrypi.com/viewtopic.php?t=35100>7 ,
That's because all the standard library modules are packed within the
micropython binary (.uf2) file you flashed to the Pico to install
micropython and are not part of the filesystem micropython exposes to the
USB host over the REPL.
So you SHOULD be able (in theory) to do this...
led_pin = machine.Pin(25, machine.Pin.OUT)
and the "machine" portion has meaning, because it is magically imported by
default without the need of implicitly being imported.
Gregwa
—
Reply to this email directly, view it on GitHub
<#11364 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOJ6HL4X6IHBUBKMH3R6BT3XEWBNTANCNFSM6AAAAAAXPGY73U>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
That is not a Micropython error but a Python error. Your IDE is connected to Python instead of Micropython The error would look this way in Micropython:
You have to import machine to use Pin, the code you posted is correct. |
Beta Was this translation helpful? Give feedback.
-
I'm just wondering...What version of Thonny are you using? Mine is 4.0.2 . I copied the RPi Forum code to my machine and ran it on my Pico-w and it worked fine.
Then I ran yours with the Pin changed from 25 to "LED" for the internal and ran it. Again, it worked just fine.
Greg |
Beta Was this translation helpful? Give feedback.
-
isn't going to work anyway. The recommended syntax is
|
Beta Was this translation helpful? Give feedback.
-
I also had this error, because I was pressing F5 (Run->Start Debugging), and apparently one is supposed to click on Run in the status bar at the bottom of the screen or Ctrl+Shift+P -> "Pico-W-Go: Run current file on Pico" |
Beta Was this translation helpful? Give feedback.
-
What version of MicroPython did you install? If you accidentally installed CircuitPython, it's incompatible, and doesn't have a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm fairly new to micropython and the pi pico but having some success.
Current problem: I'm trying to use VS Code with Pico-W-Go, which is installed and working, more or less. But when I try this sample program which came with Pico-W-Go:
I get the error "ModuleNotFoundError: No module named 'machine'"
It's interesting though, that programs run under Thonny which invoke 'machine' work OK. How can I import machine into VS Code/Pico-W-Go, or tell it where to find machine? I'm using Windows 11, BTW.
Nick
Beta Was this translation helpful? Give feedback.
All reactions