【问题标题】:Install local wheel file with requirements.txt使用 requirements.txt 安装本地 wheel 文件
【发布时间】:2020-11-07 10:05:27
【问题描述】:

有一个本地包ABC-0.0.2-py3-none-any.whl。我想通过requrements.txt将它安装在不同的项目中。例如

requirements.txt

ABC==0.0.2
Flask==1.1.2
flask-restplus==0.13.0
gunicorn==20.0.4

是否可以通过这种方式安装 ABC 包。 ABC-0.0.2-py3-none-any.whl 包含在源代码中。我不得不单独pip install ABC-0.0.2-py3-none-any.whl

【问题讨论】:

    标签: python requirements.txt


    【解决方案1】:

    这称为direct reference。从 19.1 版开始,pip support this 在命令行和需求文件中。查看官方文档中的an example(在###### 特定文件###### 下)。

    至于OP的问题,简单的把本地轮子的相对路径,即./<my_wheel_dir>/<my_wheel.whl>,放在requirement.txt中,例如,

    ./local_wheels/ABC-0.0.2-py3-none-any.whl
    Flask==1.1.2
    flask-restplus==0.13.0
    gunicorn==20.0.4
    

    【讨论】:

      【解决方案2】:

      在您的requirement.txt 文件中添加

      -f <path to the whl file>==<Version>

      然后使用python -m pip install -r <path to requirment.txt file>安装

      【讨论】:

        猜你喜欢
        • 2023-01-12
        • 2016-11-26
        • 2021-11-15
        • 2011-11-05
        • 1970-01-01
        • 2018-06-19
        • 1970-01-01
        • 2014-12-17
        相关资源
        最近更新 更多