import sys
sys.path.append("/path/to/my/modules/")
import my_module
import imp
print("Location of Python os module sources:")
print(imp.find_module('os'))
print("
Location of Python time module sources:")
print(imp.find_module('time'))
import inspect
inspect.getfile(<mdule name>)
import module_name
path = os.path.dirname(module_name.__file__)
import a_module
print(a_module.__file__)
#: say you you wanted to load/import the module 'bla.py'
#: that's sitting inside the directory '/Path/To/Modules/Dir/'
#: on your system. to have it available for import on every run
#: of the python interpreter (i.e permentantly), add the path
#: this directory to the $PYTHONPATH environment variable that
#: the Python interpreter recognizes:
export PYTHONPATH="${PYTHONPATH}:/Path/To/Modules/Dir/"
python3 -c "
import bla
"