Say that under /path/to/foo I have package with a python module:
/path/to/foo:
| my_package
| __init__.py
| my_module.py
| my_other_package
| __init__.py
| my_other_module.py
The file my_module.py does a relative import of my_other_module.py as follows:
from ..my_other_package import my_other_module
I understand that I can do the following from the shell:
> cd /path/to/foo
> python -m my_package.my_module
But what if I don't want to change my current directory? Is there any way to run my module from the shell without having to change PYTHONPATH?
I tried the following:
python -m /path/to/foo/my_package.my_module
but that didn't work. I got: Import by filename is not supported.
__init__.pyto/path/to/fooas well? I don't think you can do this iffoois not a package in itself.