当包源来自特定网站时如何格式化requirements.txt?
How to format requirements.txt when package source is from specific websites?
我正在尝试使用从另一个网站下载的 pip 将以下安装命令转换为 requirements.txt 格式,但不知道如何操作。有人可以帮忙吗?
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
structure of the contents of a requirements.txt file定义如下:
[[--option]...]
<requirement specifier> [; markers] [[--option]...]
<archive url/path>
[-e] <local project path>
[-e] <vcs project url>
<requirement specifier>
定义包和可选版本。
SomeProject
SomeProject == 1.3
SomeProject >=1.2,<2.0
SomeProject[foo, bar]
SomeProject~=1.4.2
--option
(例如,如果您从命令行执行 pip install
,您将使用 -f
/--find-links
) is the same as the pip install options。
The following options are supported:
- -i, --index-url
- --extra-index-url
- --no-index
- -c, --constraint
- -r, --requirement
- -e, --editable
- -f, --find-links
- --no-binary
- --only-binary
- --require-hashes
- --pre
- --trusted-host
因此,对于您的安装命令,requirements.txt 将如下所示:
# Torch
--find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.5.0+cu101
torchvision==0.6.0+cu101
# Detectron
--find-links https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
detectron2
确保验证链接是否正确使用:
$ pip install -r requirements.txt
Looking in links: https://download.pytorch.org/whl/torch_stable.html, https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
Collecting torch==1.5.0+cu101 (from -r requirements.txt (line 3))
Using cached https://download.pytorch.org/whl/cu101/torch-1.5.0%2Bcu101-cp38-cp38-linux_x86_64.whl
Collecting torchvision==0.6.0+cu101 (from -r requirements.txt (line 4))
Using cached https://download.pytorch.org/whl/cu101/torchvision-0.6.0%2Bcu101-cp38-cp38-linux_x86_64.whl
Collecting detectron2 (from -r requirements.txt (line 8))
Using cached https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/detectron2-0.1.2%2Bcu101-cp38-cp38-linux_x86_64.whl
...
作为旁注,您 originally said "(not github)" in your title. The default source of packages installed using pip
is hosted on PyPi: https://files.pythonhosted.org/. You can see the actual links when going to the Download Files section of a package in PyPi (example for Torch).
主要是requirements.txt是一个依赖列表:
requests
bcrypt
我正在尝试使用从另一个网站下载的 pip 将以下安装命令转换为 requirements.txt 格式,但不知道如何操作。有人可以帮忙吗?
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
structure of the contents of a requirements.txt file定义如下:
[[--option]...] <requirement specifier> [; markers] [[--option]...] <archive url/path> [-e] <local project path> [-e] <vcs project url>
<requirement specifier>
定义包和可选版本。
SomeProject SomeProject == 1.3 SomeProject >=1.2,<2.0 SomeProject[foo, bar] SomeProject~=1.4.2
--option
(例如,如果您从命令行执行 pip install
,您将使用 -f
/--find-links
) is the same as the pip install options。
The following options are supported:
- -i, --index-url
- --extra-index-url
- --no-index
- -c, --constraint
- -r, --requirement
- -e, --editable
- -f, --find-links
- --no-binary
- --only-binary
- --require-hashes
- --pre
- --trusted-host
因此,对于您的安装命令,requirements.txt 将如下所示:
# Torch
--find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.5.0+cu101
torchvision==0.6.0+cu101
# Detectron
--find-links https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
detectron2
确保验证链接是否正确使用:
$ pip install -r requirements.txt
Looking in links: https://download.pytorch.org/whl/torch_stable.html, https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
Collecting torch==1.5.0+cu101 (from -r requirements.txt (line 3))
Using cached https://download.pytorch.org/whl/cu101/torch-1.5.0%2Bcu101-cp38-cp38-linux_x86_64.whl
Collecting torchvision==0.6.0+cu101 (from -r requirements.txt (line 4))
Using cached https://download.pytorch.org/whl/cu101/torchvision-0.6.0%2Bcu101-cp38-cp38-linux_x86_64.whl
Collecting detectron2 (from -r requirements.txt (line 8))
Using cached https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/detectron2-0.1.2%2Bcu101-cp38-cp38-linux_x86_64.whl
...
作为旁注,您 originally said "(not github)" in your title. The default source of packages installed using pip
is hosted on PyPi: https://files.pythonhosted.org/. You can see the actual links when going to the Download Files section of a package in PyPi (example for Torch).
主要是requirements.txt是一个依赖列表:
requests
bcrypt