在要求 .txt 中包括 .whl 安装

Include .whl installation in requirements.txt

提问人:Abhishek Bhatia 提问时间:7/11/2017 更新时间:7/11/2017 访问量:13126

问:

如何将其包含在 requirements.txt 文件中? 对于 Linux:

pip install http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp27-none-linux_x86_64.whl 
pip install torchvision

对于 MacOS:

pip install http://download.pytorch.org/whl/torch-0.1.12.post2-cp27-none-macosx_10_7_x86_64.whl 
pip install torchvision 
python pip pytorch 要求 .txt

评论


答:

24赞 Chris Warrick 7/11/2017 #1

您可以使用环境标记

http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp27-none-linux_x86_64.whl ; sys_platform == "linux"
http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp27-none-linux_x86_64.whl ; sys_platform == "linux2"
http://download.pytorch.org/whl/torch-0.1.12.post2-cp27-none-macosx_10_7_x86_64.whl ; sys_platform == "darwin"
torchvision

(双 Linux 条目:用于 Python 2,用于 Python 3。linux2linux

评论

0赞 Abhishek Bhatia 7/11/2017
假设我更新了一个包并运行 pip freeze> requirements.txt。现在我每次都必须手动添加它们。
1赞 Chris Warrick 7/12/2017
如果你依赖于 PyPI 中没有的东西,你就不能再做得更好了。你应该说服火炬手在那里发布他们的车轮。
0赞 OrangeDog 3/15/2018
@ChrisWarrick实际上,你可以做得更好
0赞 Chris Warrick 3/17/2018
@OrangeDog Meh,pipenv 试图做得太多了。
0赞 OrangeDog 3/26/2018
好吧,它将安装一个 requirements.txt,然后为您输出一个冻结的,并保留轮子、git 链接、环境标记等。