Pymakr & Python Extension : import pycom module failure



  • Hi guys,

    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"
    import time

    pycom.heartbeat(False)

    While True:
    pycom.rgbled(0xFF0000) # Red
    time.sleep(1)
    pycom.rgbled(0x00FF00) # Green
    time.sleep(1)
    pycom.rgbled(0x0000FF) # Blue
    time.sleep(1)

    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 !



  • This post is deleted!


  • @meven

    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 !


  • administrators

    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.



  • Hi @catalin,

    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 ?


  • administrators

    hi @meven,

    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



Hello World?

Pylife on Kickstarter - November 2018








Back Us On Kickstarter >

Pycom on Twitter