Pymakr & Python Extension : import pycom module failure
Please be aware that I am a French beginner. Few days ago, I was given an Expension Board 2.0 with a LoPy4. I read the documentation and I obviously began with the "Getting Started" tutorial. First of all, I upgraded the firmware of my LoPy4 as it was required and I have installed Virtual Studio Code with Pymakr extension. I have also installed NodeJS for Pymark extension. From the pycom console itself, I could turn off the LED, change light color etc but once I have installed Python 3.6.5 with Pylint and try to run the first exemple I could not import pycom module. Here's the exemple I was trying to run on my LoPy4 with the error.
import pycom -> [pylint] E0401: Unable to import "pycom"
pycom.rgbled(0xFF0000) # Red
pycom.rgbled(0x00FF00) # Green
pycom.rgbled(0x0000FF) # Blue
I have tried to load the module pycom with the command "python -m pip install pycom" and it seems to install a pycom package but it doesn't seem to have the elements I have expected... and I went through different forum topics without finding any correct solution.
Thanks for your help !
robert-hh last edited by
This post is deleted!
What you advised: "python -m pip install pycom" is working for me also, thank you
However next, I got this error: "[pylint] E1101:Module 'pycom' has no 'heartbeat' member" but I could ignore it by:
# pylint: disable=maybe-no-member pycom.heartbeat(False) pycom.rgbled(0xffff00)
At the moment, it seems to work. Thank a lot for your explanations !
catalin last edited by
I'm not sure how to workaround this error. In principle you should be able to suppress pylint checking specific modules.
The problem is that pylint wants to make sure your python packages do exist (and you're not making some typos). But the python packages (like pycom, and all the ones explained here: https://docs.pycom.io/chapter/firmwareapi/pycom/) are embedded into the Lopy.
Pylint looks for code-source of these, but they are coded in C.
Thanks for your answer ! I tried this solution already, but it seemed silly to me as it's supposed to get errors and warning. Do I need to install another linter as mypy for example ?
catalin last edited by
This is a pylint error from Visual Studio Code. You can't pip install pycom, this a specific python package built inside Lopy.
Pylint is a static code analysis tool embedded into VSC, due to .py file extention it was enabled, by default.
You could ignore that pylint error, or try to disable pylint, like here: https://stackoverflow.com/questions/40626429/windows-10-visual-studio-code-removing-pylint