如何使 pip 运行 成为需求文件中的特定命令?

How to make pip run a specific command from requirements file?

我想在我的 requirements.txt 文件中添加 torchtorchvision 的行,以便于轻松克隆,我将在不同的计算机之间迁移到云端在不久的将来。

我想要一个简单的 pip install -r requirements.txt 并完成我的项目。

> pip freeze > requirements.txt

类似

...
torch==1.5.0
torchvision==0.6.0
...

然而,pip install -r requirements.txt(实际上是 pip install torch)不起作用,相反,作为 official torch site,明确表示命令应该是:

pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html

如何让需求文件反映这一点?

我的桌面是Windows10.


加分题:

我的云是基于 Linux 的。
如何使需求文件同时适用于桌面和云?

You can use the same options in your requirements.txt file例如

torch===1.5.0
torchvision===0.6.0
-f https://download.pytorch.org/whl/torch_stable.html

然后简单地运行pip install -r requirements.txt