29

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?

Unihedron
  • 10,902
  • 13
  • 62
  • 72
jelijelidjango
  • 431
  • 1
  • 6
  • 12
  • 1
    http://stackoverflow.com/q/4888027/4457564 answers on how to list all the available versions of a pip package – Ewa Apr 22 '17 at 14:52

3 Answers3

54

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.

Bob Stein
  • 16,271
  • 10
  • 88
  • 101
  • 2
    Best answer for me! (The accepted one does not work, for me) – f10w Jun 05 '18 at 13:09
  • This should be marked as accepted answer. – Kevin Liu Jan 20 '20 at 09:20
  • This answer worked for me. But what is this legacy-resolver thing? – Sergio Jul 14 '21 at 06:37
  • 1
    @Sergio I am guessing it's an old method for matching package names and versions to repositories. And that old method has the side effect of showing all available versions if you ask for a bogus version. Which is convenient for this answer. Unfortunately for us, the "new" "resolver" doesn't do that. (According to the link, this legacy resolver will go away soonish.) The best progress is 10% empowering and 90% annoying. – Bob Stein Jul 14 '21 at 13:21
9

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
smcs
  • 1,772
  • 3
  • 18
  • 48
enrico.bacis
  • 30,497
  • 10
  • 86
  • 115
0

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.

Huge
  • 661
  • 7
  • 14