--extra-index-url 不适用于 python requirements.txt

--extra-index-url not work in python requirements.txt

我尝试下载这个包:

echo --extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0 >requirements.txt
cat /root/requirements.txt

这是输出:

--extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0

然后下载:

mkdir -p /tmp/test
pip3 download --requirement /root/requirements.txt --dest /tmp/test

这是输出:

/usr/lib/python3/dist-packages/secretstorage/dhcrypto.py:15: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes
/usr/lib/python3/dist-packages/secretstorage/util.py:19: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes
Looking in indexes: https://pypi.org/simple, https://google-coral.github.io/py-repo/

然后列出目录:

ls -alith /tmp/test

total 8.0K
57409537 drwxrwxrwt 22 root root 4.0K Apr 27 15:48 ..
57409566 drwxr-xr-x  2 root root 4.0K Apr 27 15:48 .

pip3 无法按预期下载程序包。 non github package如何用requirements.txt下载?

requirements.txt 应该是这样的:

--extra-index-url https://google-coral.github.io/py-repo/

pycoral~=2.0

requirements.txt 文件格式规范中,--extra-index-url 选项被视为“全局选项”,必须独立于其行:

The following options have an effect on the entire pip install run, and must be specified on their individual lines.

  • --extra-index-url
  • [...]

-- https://pip.pypa.io/en/stable/reference/requirements-file-format/#global-options