Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MicroPython cannot find the module. #140

Open
QQ2046413092 opened this issue Dec 21, 2024 · 5 comments
Open

MicroPython cannot find the module. #140

QQ2046413092 opened this issue Dec 21, 2024 · 5 comments
Labels
MicroPython question Further information is requested

Comments

@QQ2046413092
Copy link

Hello, I am a beginner here. Can I ask some basic questions? I am using the micropython plugin to write code, and I have created a new project. However, I am facing a problem where modules located in the same directory as the project cannot be imported. When I run the code, it gives an error saying that the module cannot be found.

@QQ2046413092
Copy link
Author

There is another issue where, when running a MicroPython project and disconnecting the circuit board suddenly, the "Run" button in the status bar of Visual Studio Code will become stuck and will not stop, even after trying to reconnect the circuit board and stopping. The only solution is to restart Visual Studio Code or the extension.

@frohro
Copy link

frohro commented Dec 23, 2024

I don't know if this is the same bug, but if I start a new MicroPython project, and let it suggest the Blink project, it cannot find the module machine. I can copy the Blink project into Thonny and it runs beautifully.

@paulober paulober added MicroPython question Further information is requested labels Dec 23, 2024
@paulober
Copy link
Collaborator

Hello, I am a beginner here. Can I ask some basic questions? I am using the micropython plugin to write code, and I have created a new project. However, I am facing a problem where modules located in the same directory as the project cannot be imported. When I run the code, it gives an error saying that the module cannot be found.

Thank you for reaching out! The issue you're experiencing occurs because the modules are located on your host machine and not on the Pico itself. When you execute a script on the Pico, its Python interpreter cannot resolve or access those modules unless they are uploaded to the device.

To resolve this, I recommend uploading either the entire project or just the specific modules you need to the Pico before running your script. Keep in mind that if you update any of the modules locally, you will need to upload the changes again to test them on the Pico.

@paulober
Copy link
Collaborator

I don't know if this is the same bug, but if I start a new MicroPython project, and let it suggest the Blink project, it cannot find the module machine. I can copy the Blink project into Thonny and it runs beautifully.

How do you execute the blink script? (Keep in mind that the default run button does not work if you want to execute the script on the connected Pico. Instead I recommend the run button contributed by the extension in the toolbar, the context menu or as command in the command palette)

@frohro
Copy link

frohro commented Dec 24, 2024

@paulober you solved my issue. I was using the regular "Run" command at the top. The one in the toolbar works fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MicroPython question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants