check version of pip packages available before installing

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.


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

Tags:

Python

Pip