Quantcast
Channel: Import module from subfolder - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Rob Wouters for Import module from subfolder

$
0
0

There's no need to mess with your PYTHONPATH or sys.path here.

To properly use absolute imports in a package you should include the "root" packagename as well, e.g.:

from dirFoo.dirFoo1.foo1 import Foo1from dirFoo.dirFoo2.foo2 import Foo2

Or you can use relative imports:

from .dirfoo1.foo1 import Foo1from .dirfoo2.foo2 import Foo2

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>