traschik
traschik

Reputation: 181

How to know what python version a package is compatible with

I tried to install an old version of a python package and got the Could not find a version that satisfies the requirement... error. I am confident that the package and the specified version do exist, and I have learned that this problem often occurs when the package is incompatible with the python version.

How do I find out what python version I need without installing them all and trying pip install until it works?

Upvotes: 17

Views: 51418

Answers (5)

mirekphd
mirekphd

Reputation: 6743

You can search Github Issues in your package repo for your version of python, e.g. for Flask support under python 3.11:

https://github.com/pallets/flask/issues?q=%22python+3.11%22+is%3Aissue+


Note: don't be afraid of using the quotes, it is a very intelligent search, so for example "python 3.11" will find pages containing:

  • Python version: 3.11
  • Python version 3.11 - Failed
  • Python 3.11 introduced native TOML support with the tomllib package.
  • Python version: 3.10 and 3.11
  • #7 0.687 + python 3.11.3 h2755cc3_0_cpython conda-forge 0 B

... but will miss Q&A like this:

  • Q. "OK .. so which one version of the python you are using?"
  • A. "3.11" (this could be found by searching for 3.11, which returns also false positives, i.e. random packages with version 3.11 from long lists of requirements posted in some issues).

Upvotes: 1

Flo
Flo

Reputation: 129

Combining this answer and that answer led me to a working solution with Python 3.10.8 (and pip>=2.22):

python -m pip install numpy== --dry-run --python-version 2.4 --no-deps --target foo

Output:

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)
ERROR: No matching distribution found for numpy==

Note that if you are only looking for the latest version (not the whole list) of a package compatible with a given Python version you can also run:

python -m pip install numpy --dry-run --python-version 3.11 --no-deps --target foo | grep Would

Output:

Would install numpy-1.25.0

Upvotes: 8

Prathamesh
Prathamesh

Reputation: 1057

The simplest but manual approach I've found for this problem was:

e.g.:

which gives you lists of packages supported (in green) and not yet supported (in white) by python in a given version, as well as the percentage of readiness (ranging from 3% for betas to 80%+ for the most established ones (currently python 3.8).

This might not be the best approach but for someone looking for just whether a package is supported by a given python version its the easiest approach!

Upvotes: 2

Andrew Swanton
Andrew Swanton

Reputation: 51

If you want a more automated of finding this out you can trick pip into showing you. When you try to install a version of a package which doesn't exist pip provides you with a list of packages available.

pip install numpy==missing

In the response we can see all the versions

ERROR: Could not find a version that satisfies the requirement numpy==missing (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, 1.20.3, 1.21.0rc1, 1.21.0rc2, 1.21.0, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.22.0rc1, 1.22.0rc2, 1.22.0rc3, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0rc1, 1.23.0rc2, 1.23.0rc3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4) ERROR: No matching distribution found for numpy==missing

If you want to test availability for a version of python which you are not running (in my case version 2.4) then you need to do the following.

pip install --python-version 24 --no-deps --target test-pkg numpy==missing

Note the options --no-deps --target are required for us to run --python-version

ERROR: Could not find a version that satisfies the requirement numpy==missing (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) ERROR: No matching distribution found for numpy==missing

Tested on python version 3.5, pip==20.2.3

Upvotes: 4

luuk
luuk

Reputation: 1855

You can look up the package on the Python Package Index and scroll down to the "Meta" section in the left sidebar. This shows the Python version required by the package. As you do not specify the package you are looking for, I will use numpy as an example. For the current version of numpy, the following information is listed:

Requires: Python >=3.7

Therefore, you need Python 3.7 or higher to install this version of numpy.

If you are using an older version of Python and need the most recent version of the package that is compatible with that version, you can go to the release history (the second link at the top of the sidebar) and try different versions, scrolling down to the "Meta" section for every version. This is still a manual process, but less work than trying to install every single version.

Note: often, support for older versions is dropped in larger updates (so when either the first or second version number is updated), so you can skip small updates to speed up your search process.

For example, using this process, you can deduce that numpy 1.19.5 is the latest version to support Python 3.6, and numpy 1.16.6 is the latest version to support Python 2.7. At the top of the page, the command to install an older version of a package is shown, for example: pip install numpy==1.16.6.

Upvotes: 10

Related Questions