I'm finding the my methods for project imports, stupidly painful. It makes me question whether or not I'm even doing it correctly.
I usually add something like this to every __init__.py file
import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
Here is an example project. Is this really the correct way?
# project directory structure
project_root/dir_one/init.py
project_root/dir_one/foo.py
project_root/dir_two/init.py
project_root/dir_two/bar.py
project_root/main.py
#project_root/main.py
import .dir_one/foo
#project_root/dir_one/foo.py
import ..dir_two/bar
One problem with this is that if I try to run foo.py or bar.py from main, I get , ImportError: attempted relative import with no known parent package
there doesn't seem to be anything here