Unable to import pycom in VScode



  • Hi there,
    I am a complete beginner here. Recently got a LoPy4 with the expansion board and was just following the tutorials on the pycom website for controlling the RGB LED light on the LoPy4 board. I am currently using VScode for this and i followed all the steps: creating main. py and boot. py files as well as the lib folder.

    When I import the files in the Terminal it seems to work just fine. I am able to call:

    >>> import pycom
    >>> pycom.heartbeat(False) 
    

    however, when I try to run this in the main. py file, It gives me an error in the terminal saying

    ModuleNotFoundError: No module named 'pycom' 
    

    and under the 'problems' tab it says:

    Unable to import 'pycom' pylint(import-error) [1, 1]
    

    The fact that it works in the terminal (Pymakr Console) gives me the impression that it's something to do with VScode not being able to find pycom module somehow, as I am also able to import other Python modules just fine such as time or random.

    I can't really move any further until I fix this but I haven't found a solution online.

    Any solutions to this would be much appreciated! Thanks.



  • @Gijs Hi. Yes, I have the Python plugin but I also have the Pymakr plugin installed. It seems as though when i run the code it uses the python extension by default. I found that if I say Ctrl + Shift + R (or use the run current file in the bottom toolbar), it is able to run the file just fine. But it still flags it as a problem and tells me

    Unable to import 'pycom' pylint(import-error) [1, 1]
    

    as well as giving me the red underline where i typed 'import pycom'



  • Hi,

    I have not seen this issue before, but it seems like you are using python on your computer instead of in Pymakr. Do you perhaps have the VSCode python plugin installed?

    Best,
    Gijs


Log in to reply
 

Pycom on Twitter