• Advertisement
Sign in to follow this  

Python Module Import Question

This topic is 2417 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have several years of programming experience, but I have been learning python recently and I'm having trouble understanding its import behavior. I've got a project with a namespace tree, and I've got a test file that I'm importing modules from the project into. Something like this: "import some.cool.thing as thing." Well, some/cool/thing.py then tries to import a local module some/cool/anotherthing.py using "import anotherthing" This fails with a "No module named anotherthing" error. It does not fail, however when I use "import some.cool.anotherthing." So basically it wants the fully qualified namespace path.

I didn't write the code, and there are dozens of imports like this that are done locally. Is there some setting I need to change to make python look in the local directory of the module that's doing the import? It seems like I shouldn't have to use the full namespace name for everything.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement