python如何导出项目依赖【pipreqs】

1、导出python环境中的所有依赖

pip freeze >requirements.txt

此方法会导出python环境所有安装过的依赖

2、仅导出当前项目中的依赖

  • 需要使用pipreqs这个工具
  • 安装
    pip install pipreqs
  • 然后进入项目的根目录,并执行
    pipreqs . --encoding=utf8 --force

    【.】:表示生成的requirements.txt文件所在目录,即当前目录下
    【--encoding=utf8】:指定文件编码
    【--force】:如果已经存在requirements.txt,则强行覆盖

posted @ 2024-03-22 12:45  eliwang  阅读(26)  评论(0编辑  收藏  举报