If you want to import a module that doesn't already exist as a built-in module in the Python Standard Library nor as a side-package, you can do this by adding the path to the directory where your module is found to sys.path
. This may be useful where multiple python environments exist on a host.
import sys
sys.path.append("/path/to/directory/containing/your/module")
import mymodule
It is important that you append the path to the directory in which mymodule
is found, not the path to the module itself.