Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Unable to import pycom in VScode

    Scheduled Pinned Locked Moved LoPy
    3 Posts 2 Posters 120 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      hm97
      last edited by hm97

      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.

      1 Reply Last reply Reply Quote 0
      • G Offline
        Gijs
        last edited by

        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

        H 1 Reply Last reply Reply Quote 0
        • H Offline
          hm97 @Gijs
          last edited by

          @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'

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom