I am probably missing something obvious but anyway:
When you import a package like os in Python, you can use any submodules/subpackages off the bat. For example this works:
>>> import os
>>> os.path.abspath(...)
However, I have my own package which is structured as follows:
FooPackage/
__init__.py
foo.py
and here the same logic does not work:
>>> import FooPackage
>>> FooPackage.foo
AttributeError: 'module' object has no attribute 'foo'
What am I doing wrong?
You need to import the submodule:
What you’re doing is looking for
fooinFooPackage/__init__.py. You could solve it by puttingimport FooPackage.foo as foo(orfrom . import foo) inFooPackage/__init__.py, then Python will be able to findfoothere. But I recommend using my first suggestion.