有一个本地包ABC-0.0.2-py3-none-any.whl
。我想通过requirements.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
。
这被称为直接引用。自19.3版本以来,pip在命令行和需求文件中都支持这一点。查看官方文档中的一个示例。
关于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
对于使用setuptools的pyproject.toml
文件,本地语法./local_wheels/ABC-0.0.2-py3-none-any.whl
不起作用。
这项工作:
tensorflow @ file://localhost/pip-wheels/aarch64/tensorflow-2.8.4-cp38-cp38-linux_aarch64.whl
需要file://localhost/
+绝对路径。
pip问题也许可以解释原因。
在requirement.txt
文件中添加
-f <path to the whl file with file name>==<Version>
然后使用python -m pip install -r <path to requirement.txt file>
进行安装