Import modules from an arbitrary filesystem location

suggest change

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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents