ImportError even module is in the same folder
-
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 -
@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. -
@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. -
@robert-hh that's true, you can have the libraries anywhere (with Pymakr as well)
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