【问题标题】:How to exclude a package that exists on requirements.txt during installation?如何在安装过程中排除 requirements.txt 上存在的包?
【发布时间】:2022-07-12 00:58:55
【问题描述】:

有一个关于freezing into requirements.txt 的问题here,但这个问题是关于installing from requirements.txt。 我在远程服务器上有一个requirements.txt 文件:

Pillow==8.2.0
nltk==3.6.2
notebook==6.4.0 #numpy==1.19.5

& 然后我意识到我想在运行时排除 notebook==6.4.0
pip install -r requirements.txt。我们怎样才能做到这一点?

一种可能性:我可以 commentdelete 来自 local server's requirements.txt 的不需要的包,然后将 git 推送回远程服务器。如何在不访问本地服务器的情况下排除包?谢谢。

【问题讨论】:

    标签: python-3.x installation pip remote-server requirements.txt


    【解决方案1】:

    此问题的常见解决方案是使用 nested requirements.txt

    1. requirements.txt 中的生产包:
    Pillow==8.2.0
    nltk==3.6.2
    numpy==1.19.5
    
    1. requirements_dev.txt 中的开发包
    -r requirements.txt  # <- installs production packages
    notebook==6.4.0
    

    ...一如既往:ReadTheDocs

    【讨论】:

    • 感谢您的提示,这些提示将在未来的开发中应用。现在我想要一些东西来摆脱目前的混乱局面。
    猜你喜欢
    • 2017-12-14
    • 1970-01-01
    • 2015-06-27
    • 2020-03-18
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    • 2023-01-19
    • 2022-11-10
    相关资源
    最近更新 更多