Auto install third part packages by pip into virtual environment when import error.
Project description
ensure_import
Auto install third part packages by pip into virtual environment when import error.
Install
pip install ensure_import
Usage
- Simple case that package name is module name
from ensure_import import EnsureImport
for _ in range(EnsureImport.retry):
with EnsureImport() as _m:
import uvicorn
from fastapi import FastAPI
if _m.ok:
break
- Package name is difference from module name
for _ in range(EnsureImport.retry):
with EnsureImport(dotenv='python-dotenv', odbc='pyodbc') as _m:
import numpy as np
import uvicorn
import odbc # who's package name is `pyodbc`
from fastapi import FastAPI
# package name of dotenv is `python-dotenv`
from dotenv import load_dotenv
if _m.ok:
break
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ensure_import-0.2.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for ensure_import-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe6ffa4ff15b671982ea41c764785162148a0532b244803a46348d45a8a65b8f |
|
MD5 | df6a2214479f653e853b4d9f63fb26ee |
|
BLAKE2b-256 | 90a458702b5ab545e3294abb2e4c116d58298aa0ee9b6d3bf8f4f74d7cf112a8 |