Home > Software design >  --extra-index-url not work in python requirements.txt
--extra-index-url not work in python requirements.txt

Time:04-27

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?

CodePudding user response:

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

CodePudding user response:

Why would you do that this way ?

I'd simply download the wheel and install it :

wget https://github.com/google-coral/pycoral/releases/download/v2.0.0/pycoral-2.0.0-cp39-cp39-linux_x86_64.whl
pip3 install pycoral-2*.wheel
  • Related