0

Idea is to import package or install it if not found from inside of python script Basically my problem is in ability of importing package with passing string with name instead of name

import "time"               # this is invalid syntax
print(time.localtime())

Full script

requirements = 
{"jupyterlab":"python -m pip install jupyterlab",
"pandas":"python -m pip install pandas"}

for key in requirements:
    try:
        import key
    except:
        import os
        os.system(requirements[key]) 

Maybe it can be solved some other way, but i am not familiar with that (except docker)

0 Answers0