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.1.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for ensure_import-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5043b6b35c35adbd379c0949b633a17768d8cd11f20c16e706a7a4c0b76f582d |
|
MD5 | e2bdb406356eb331a57615610bf7289b |
|
BLAKE2b-256 | 7070e110d8946455744c13283bd327c67a85ebc8d18c9d31debd3b1a95b60a81 |