check version of pip packages available before installing

Question:

I want to know what version of a package pip has available before I install it. I understand that you can check the version of the packages you have installed with “pip show” but I want to check which package versions pip has available in its archive. And then once I identify them, how do you pick a specific one to install?

Asked By: jelijelidjango

||

Answers:

For newer versions of pip as of Dec 2020, you should use:

pip download -v packagename

For older versions of pip you can use:

pip install --download . -v packagename

Both above commands will download the files without installing and will also show all the version of a package (you can stop the command after that). After that, to install a specific version use:

pip install packagename==version
Answered By: enrico.bacis

Not general, but going to PyPI (https://pypi.org/) first should give you the idea of the stable version which most likely pip would download.

Answered By: Huge

pip install --use-deprecated=legacy-resolver foobar==

--use-deprecated=legacy-resolver is required after pip 20.3

To see all versions, install a nonexistent version, which can be the empty string. [thanks @ChrisMontanaro, @JanKyuPeblik]

$ pip install --use-deprecated=legacy-resolver numpy==
ERROR: Could not find a version that satisfies the requirement numpy== 
(from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 
1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 
1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 
1.11.3, 1.12.0, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3, 
1.14.0rc1, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 
1.15.0rc1, 1.15.0rc2, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0rc1, 
1.16.0rc2, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 
1.17.0rc1, 1.17.0rc2, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 
1.18.0rc1, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0rc1, 
1.19.0rc2, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0rc1, 
1.20.0rc2, 1.20.0, 1.20.1, 1.20.2)
ERROR: No matching distribution found for numpy== 

Then you can install one of them:

$ pip install numpy==1.20.2
Collecting numpy==1.20.2
  Downloading numpy-1.20.2-cp38-cp38-win_amd64.whl (13.7 MB)
     |████████████████████████████████| 13.7 MB 6.4 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.20.2

The p==x Requirement Specifier means install package p version x.

Answered By: Bob Stein
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.