简体   繁体   中英

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

I try to download this package:

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

Here is the output:

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

Then download:

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

Here is the output:

/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/

Then list the directory:

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 .

The pip3 can't download the package as expected. How to download with requirements.txt for this non github package ?

The requirements.txt should probably look like this:

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

pycoral~=2.0

In the requirements.txt file format specification, the --extra-index-url option is considered a "global option" and has to be isolated on its own line:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM