Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Pip claim that a version of Python is not in a given range?

I am using Python 3.8.7 and the latest version of Pip, v21.0.1. I have written a package that contains the following Python version constraint:

python_requires='>=3.6, <3.9',

When I try to install the package, Pip refuses and prints the following error:

ERROR: Package 'my-package' requires a different Python: 3.8.7 not in '<3.9,>=3.6'

I have seen a similar error when installing other packages with similar version constraints:

ERROR: Package 'my-other-package' requires a different Python: 3.8.7 not in '!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,<3.9,>=2.7'

Clearly Python 3.8.7 is greater than 3.6 and less than 3.9, so why does Pip claim that a different version of Python is required?


Some investigation suggests that this may be an inaccurate error message. I have run an experiment uses packages with the following dependent relationship:

  • package-a requires Python >= 3.6, and depends on package-b;
  • package-b requires Python >= 3.6 and < 3.9.

I have found that when installing package-a using Python 3.9, I receive the following error:

ERROR: Package 'package-a' requires a different Python: 3.9.0 not in '>=3.6'

So basically, package-a cannot be installed with Python 3.9 because package-b does not work with Python 3.9; however, Pip erroneously states that package-a requires a "different" Python, and then erroneously prints out package-a's version specifier, rather than package-b.

I will continue to investigate, but this may be a bug in Pip itself.

like image 696
mipadi Avatar asked Mar 12 '21 01:03

mipadi


People also ask

What version of Python is pip using?

PIP is automatically installed with Python 2.7.9+ and Python 3.4+ and it comes with the virtualenv and pyvenv virtual environments. Before you install PIP on Windows, check if PIP is already installed.

How do you fix could not find a version that satisfies the requirement?

To Solve Could not find a version that satisfies the requirement Error You just need to update pip and your error will be resolve.

How do I install a specific version of a python package?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .

Does pip automatically install latest version?

Using Requirements Files. The pip install command always installs the latest published version of a package, but sometimes your code requires a specific package version to work correctly.


1 Answers

This was a bug in pip and has been fixed in version 21.1 (see #9541). Specifically, it included the wrong Python constraint (the one of a dependency) in the error message when resolution failed.

like image 194
a_guest Avatar answered Oct 12 '22 15:10

a_guest