【发布时间】:2016-05-12 20:06:46
【问题描述】:
我想知道我的 python 脚本是否可以在尝试导入模块之前安装它。当我现在运行我的脚本时,它会尝试导入模块(当然),但我希望它安装模块,然后检查它是否可以导入它。
更新 1
这是我想在运行脚本时使用的安装脚本:
def install():
print("\nChecking for dependencies, please stand by...")
with hideInfo():
if str(os.name) == 'nt':
easy_install.main(['textract'])
pip.main(['install', 'logging'])
pip.main(['install', 'datetime'])
else:
pip.main(['install', 'textract'])
pip.main(['install', 'logging'])
pip.main(['install', 'datetime'])
time.sleep(1)
menu()
【问题讨论】:
-
这能回答你的问题吗? Installing python module within code
标签: python import module installation