模拟 pip -f 选项的 pipenv 选项

pipenv option to mimic pip -f option

在 pip 中有一个 -f 选项,它执行以下操作:

-f, --find-links : If a url or path to an html file, then parse for links to archives. If a local path or file:// url that's a directory, then look for archives in the directory listing.

这是安装 PyTorch 的首选方式,通过将 link 设置为其概览网站,例如:

pip3 install torch===1.3.0 -f https://download.pytorch.org/whl/torch_stable.html

对于我的虚拟环境,我使用 pipenv,但我还没有找到与 -f 功能相同的选项。同时,我可以直接link查找与我的系统相关的包,但这很麻烦。

pipenv 是否提供了与 pip 的 -f 相同的方法?

目前,我还没有找到解决方法。当然,你可以做的是启用 pipenv shell 并使用 pip 做你必须做的事情,例如

pipenv shell
python -m pip install torch===1.3.0 -f https://download.pytorch.org/whl/torch_stable.html

这将在 pipenv 环境中安装 torch 但是 torch 不会添加到 Pipfile(也不会添加到锁定文件)。

可以使用 pip 识别的环境变量来调整其在 pipenv 执行中的行为。例如:

PIP_FIND_LINKS=https://download.pytorch.org/whl/torch_stable.html pipenv install torch==1.5.1+cu101

参见:

在新版pipenv中(我测试的是2020.11.15版本),可以这样安装包:

pipenv install https://download.pytorch.org/whl/cpu/torch-1.3.0%2Bcpu-cp36-cp36m-linux_x86_64.whl

link 可以在这个页面找到:https://download.pytorch.org/whl/torch_stable.html

这也将添加到 Pipfile。

[packages]
torch = {file = "https://download.pytorch.org/whl/cpu/torch-1.3.0%2Bcpu-cp36-cp36m-linux_x86_64.whl"}

您需要使用您的计算平台、os 和 python 版本手动检查 link。