1

I'm a complete beginner and I recently got the LoPy4 development board as well as the expansion board. I am currently following the tutorial on changing the RGB lights on the board. I have been following the steps such as installing the Pymakr extension on VSCode and making the main.py and boot.py files. I am able to call import pycom in the Pymakr console and I am then able to turn off the heartbeat using pycom.heartbeat(False).

However, when I try the same thing by typing it in the main.py file, I get an error:

ModuleNotFoundError: No module named 'pycom'

There seems to be no issue with importing the other modules like import time or import random.

Anyone have any ideas what's the problem here?

help-info.de
  • 6,695
  • 16
  • 39
  • 41
hm97
  • 13
  • 3
  • do you get the error when you run the program or while you write it? VS Code doesn't natively support MicroPython. So it is normal not to recognize certain things as you type them. – George Bou Aug 31 '20 at 13:33
  • I think it's when I run the script. I have found however that when I hit the run button on the top right of VScode, it seems to run it on the Python console and not the Pymakr console, but when I hit the run button on the bottom toolbar, it runs it on the pymakr console just fine, giving me the desired results. But it still flags it as a problem, giving me that red underline under 'import'. Also, note that the IntelliSense (I think that's what you call the autocomplete) does not predict the pycom module. – hm97 Sep 01 '20 at 20:11

1 Answers1

0

Think of this as having access to two Pythons :

  • Python,

    • installed on your PC,
    • used by VSCode to do syntax checking and Debugging
    • does not know about Pins and any pyboard specific modules
    • if you run ▶ or Debug (F5) in VScode , it will attempt to run / debug your code on your PC ( which may fail )
  • MicroPython

    • running on your board
    • accessible though Pymakr
    • knows about the pins and the pyboard module

Pymakr gives you : enter image description here

  • a connection from VScode to the MicroPython terminal
  • a method to sync/upload/download files beetween your PC and the MCU board
  • an ability to Upload and Run a .py file ( upload from PC to board , then run on the board )
  • an ability to execute a few lines of code from your current file to the board (think of it as a copy & paste )I assign the F8 or ctrl-Shift-Enter hotkey to this

to improve things like syntax checking for MicroPython I have created a few tools to make make the `Big Python' act more like the Micro Python.

MicroPython Stubber

and has been packaged as micropy-cli by Braden for simple use

You can download and install the latest version of this software from the Python package index (PyPI) as follows:

pip install --upgrade micropy-cli

If applicable, you can test out a pre-release by executing:

pip install --upgrade --pre micropy-cli

After setup and a simple config the two pythons will get along much better. demo

You'll still need to be aware which of the two Pythons you are dealing with, but it should help you.

Jos Verlinde
  • 1,468
  • 12
  • 25