自动创建 requirements.txt

问题描述

有时我从 github 下载 python 源代码,但不知道如何安装所有依赖项.如果没有 requirements.txt 文件,我必须手动创建它.
问题是:
给定 python 源代码目录,是否可以从导入部分自动创建 requirements.txt?

解决方案

使用 建议使用 Pipenv 或其他工具来改进您的开发流程.

pip3 冻结 >requirements.txt # Python3点冻结>requirements.txt # Python2

如果你不使用虚拟环境,pigar 会是你不错的选择.p>

Sometimes I download the python source code from github and don't know how to install all the dependencies. If there is no requirements.txt file I have to create it by hands.
The question is:
Given the python source code directory is it possible to create requirements.txt automatically from the import section?

解决方案

Use Pipenv or other tools is recommended for improving your development flow.

pip3 freeze > requirements.txt  # Python3
pip freeze > requirements.txt  # Python2

If you do not use a virtual environment, pigar will be a good choice for you.

相关文章