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 · 8 comments
Open

MicroPython cannot find the module. #140

QQ2046413092 opened this issue Dec 21, 2024 · 8 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!

@allaire
Copy link

allaire commented Jan 19, 2025

@paulober This thread helped, thanks.

Could you please explain me how the run command works exactly? Does it uploads the current open file every time I press run on the Pico?

When I press run, the code executes correctly on my pico, then I unplug it and run it on power source, but then pico does not contains my last changes from the last run. I have to plug it again and choose "upload project to pico".

I haven't found anything about that in the doc

@paulober
Copy link
Collaborator

@allaire Of course. The run button/command does copy and execute the contents of the currently open file but it doesn't store it. Another option would be do a right click in the editor and select Upload file to Pico if you want to copy the latest changes of this one file.

@allaire
Copy link

allaire commented Jan 20, 2025

Brilliant thank you so much.

@will-v-pi will-v-pi mentioned this issue Jan 22, 2025
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

4 participants