Jump to content
  • Advertisement
Sign in to follow this  
ZachBethel

Python Module Import Question

This topic is 2541 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.

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Well, just 20 minutes after posting this I figured out that I needed to edit the PYTHONPATH environment variable to match the directory.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!