当上传到GitHub时,你可能想要包含一个requirements.txt文件。我已经创建了一个虚拟环境,因此pip3 freeze只列出了我在项目开发期间安装的包。然而,我也安装了pylint (由VS Code建议),这是我不希望在需求文件中使用的。当我使用pip3 freeze时,Pylint没有在一个条目中列出。那么,有没有办法从需求中删除pylint和相关的东西呢?最坏的情况是,有没有人能列出所有pylint的东西,这样我就可以手动从需求文件中删除它们?
发布于 2020-08-30 22:13:12
假设您正在使用pip (而不是像Poetry这样的其他管理器),您可以使用pip-tools来处理此场景。首先,将您的需求手动写入一个文件:
$ cat requirements.in
# assuming your project uses only following dependencies
django
gunicorn然后,您可以生成整个依赖关系图:
$ pip-compile requirements.in
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
asgiref==3.2.10 # via django
django==3.1 # via -r requirements.in
gunicorn==20.0.4 # via -r requirements.in
pytz==2020.1 # via django
sqlparse==0.3.1 # via django^这是您用于生产的requirements.txt。对于开发依赖项,您可以执行相同的操作,但将它们保存到一个单独的文件中,以便您可以在需要时安装它,但它与运行时依赖项保持分离:
$ cat requirements-dev.in
# development requirements
pylint
mypy
pytesthttps://stackoverflow.com/questions/62467118
复制相似问题