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

    ImportError even module is in the same folder

    Scheduled Pinned Locked Moved SiPy
    importerrormoduleslocation
    4 Posts 3 Posters 566 Views 4 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.
    • B Offline
      brossingo
      last edited by

      Hi,
      I am new with Pycom and Python in general. I am working on a new project and since then, keep struggling with the same issue. I cannot import modules I need. For example, if I need the onewire module and its OneWire class, I get this error "ImportError: no module named 'onewire'", even if I put it in the same project folder where my main code is. For now, I put the whole definition of the class and its methods in my main to avoid the importation but this makes a really long code then. I already read many topics about that, especially about adding manually the modules with sys.path.insert/append and modifying the Python Path but it still does not work. I am using Atom as IDE and I download Pymakr to have an REPL.
      I can provide you with further information if needed.
      Thanks for your help

      danD 1 Reply Last reply Reply Quote 0
      • danD Offline
        dan @brossingo
        last edited by

        @brossingo you need to put the libraries in the lib/ folder. To use the OneWire lib, here's how you can import it: from onewire import OneWire. You can find a basic example here.

        robert-hhR 1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @dan
          last edited by

          @dan Not to my experience. Libraries and module can be in any folder specified in sys.path. And the default includes the local directory at first place. I almost never use the lib folder.
          But pymakr may play it's own game.

          danD 1 Reply Last reply Reply Quote 0
          • danD Offline
            dan @robert-hh
            last edited by

            @robert-hh that's true, you can have the libraries anywhere (with Pymakr as well)

            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