Tools for improving Python imports

PyPI

Tools for improving Python imports.

Installation

Docs

import_from_path()

Import a module from any path on the filesystem.

Usually, this would be achieved by adding the parent directory of the module to
sys.path or the PYTHONPATH environment variable. However, this pollutes the
import path and can lead to accidentally importing the wrong modules. The
function import_from_path() avoids this problem by importing a package from a
search path without modifying the Python import path.

The module can be either a directory containing __init__.py or a single file.

Relative paths are resolved relative to the source file that calls
import_from_path().