I have a package with the following hierarchy
my_package/__init__.py
script_a.py
scripts_dir/__init__.py
script_b.py
my_package/__init__.py
module_a.py
module_b.py
module_a and module_b contain function and class definitions that I am using in script_a and script_b (which are stand alone scripts and contain a main)
When I import something from let's say module_a.py in my script_a.py everything is fine.
My problems are
- I cannot figure out how to use relative imports to import something from module_a or module_b to script_b.py
I am not sure if I am supposed to use relative imports or if it makes more sense to add my_package to sys.path and then use something like
from my_package.module_a import the_funky_func
I want to avoid having to call the interpreter with the
-m
argument
update
From the answers I have found so far in SO I have concluded that I have 3 options
write a setup to include the package to my PYTHONPATH so that all scripts regardless of where they are can call the modules
use the
-m
argument when invoking the interpreterdo some sys.path hack
Is there another option that I am not aware of?