使用pycharm导出程序所使用的的依赖包

导出程序所使用的的依赖包,并生成requirements文件
import os, sys

# 找到当前目录
project_root = os.path.dirname(os.path.realpath(__file__))
print(project_root)

# 找到解释器,虚拟环境目录
python_root = sys.exec_prefix
print(python_root)

# 拼接生成requirements命令
command = python_root + '\Scripts\pip freeze > ' + project_root + '\\requirements.txt'
print(command)

# 执行命令。
os.system(command)

 



posted @ 2019-09-18 15:04  想扣篮的小矮子  阅读(4163)  评论(0编辑  收藏  举报