pip install with extra index url to requirements.txt

Question:

I have following install comand for a package:

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116

and would need to add this to my requirements.txt file. I have done it by adding this to the end of the file:

-i https://download.pytorch.org/whl/cu116
torch
torchvision 
torchaudio

after all the other requirements.
I do not have the means to test it right now, and would need to know if I have done it correctly as I never did it before.

Is this the proper way of adding it to the requirements.txt file?

If yes, adding other packages after these, for example numpy, will it be affected by the url? do I have to sort of "clear" the url, or is it simply added to the list of urls it searches in?

Any help appreciated

Asked By: sharkyenergy

||

Answers:

Found the solution, the command you used and the requirements.txt file were NOT in fact the same. It works with a requirements.txt like this

--extra-index-url https://download.pytorch.org/whl/cu116
torch
torchvision 
torchaudio

Turns out -i is not the same as --extra-index-url.

Docs: https://pip.pypa.io/en/stable/reference/requirements-file-format/

Answered By: Matthias
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.