Linux 中 Python 生成的 requirements.txt 很多库都是根本用不到的这是什么情况?

目录:项目主目录
使用命令:pip freeze > requirements.txt
生成的 requirements.txt 如图:
clipboard.png

我打开看了一下,发现大部分根本就不是该项目所需要的库。这是什么情况?我理解错了? pip freeze 是把所有在本机上安装的库导进 requirements.txt 中?

阅读 6.5k
1 个回答

pip freeze 导出当前环境中所有的python 库列表
你这种,没有用virtualenv ,所以会导出系统安装的python库

建议你换 pipreqshttps://github.com/bndr/pipreqs
分析 import语句,导出 python 库列表

Why not pip freeze?

  • pip freeze only saves the packages that are installed with pip install in your environment.
  • pip freeze saves all packages in the environment including those that you don't use in your current project. (if you don't have virtualenv)
  • and sometimes you just need to create requirements.txt for a new project without installing modules.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题