deferred-import
Lazy import and install on demand Python packages.
- Package will be loaded only when you use it in the first time. Deferring it makes module loading much faster.
- If module is missed, the package will be automatically installed. It allows to make some project dependencies optional and install them on demand.
Installation
python3 -m pip install --user deferred-import
Usage
from deferred_import import deferred_import
requests = deferred_import('requests')
attr = deferred_import('attr', package='attrs')
requests.get('http://httpbin.org/status/200')