导出到文件
pip freeze >packages.txt
批量安装
pip install -r packages.txt
使用代码导出
import os installed_module_list = os.popen("pip freeze") # print(installed_module_list) with open("requirements.txt",'w') as f: for m in installed_module_list.read(): f.write(m)