pip icon indicating copy to clipboard operation
pip copied to clipboard

Resolver reports “conflict” between requirement and constraint when the intersection does not contain an installable distribution

Open andy-maier opened this issue 3 years ago • 6 comments

Description

Consider the following files:

requirements.txt:

pywin32>=227

minimum-constraints.txt:

pywin32==227

Then pip fails installing this requirements file with the constraints file, reporting a conflict:

$ pip install -c minimum-constraints.txt -r requirements.txt 
ERROR: Cannot install pywin32>=227 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested pywin32>=227
    The user requested (constraint) pywin32==227

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

This conflict was originally reported in a GitHub Actions run with pip 21.2.2 on Python 3.10 on Windows (see this log). In these runs, the conflict was not reported with any other Python version on Windows (down to Python 3.6, pip 21.2.2 was used). The pywin32 package is only used on Windows.

The conflict is reproducable with the simplified files shown above and with the latest released version 21.3.1 of pip on at least Python 3.9 and 3.10 on macOS (I assume the win-only nature of pywin32 does not matter for the conflict checking).

If another package with M.N versioning is used, pip does not report a conflict. For example, using ordereddict==1.1 and ordereddict>=1.1:

$ pip install -c minimum-constraints.txt -r requirements.txt 
Collecting ordereddict>=1.1
  Downloading ordereddict-1.1.tar.gz (2.1 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: ordereddict
  Building wheel for ordereddict (setup.py) ... done
  Created wheel for ordereddict: filename=ordereddict-1.1-py3-none-any.whl size=3552 sha256=aac5902de79601db7205c452969a2da6cfadb94573a1a4a6e1fb42e7ff217037
  Stored in directory: /Users/maiera/Library/Caches/pip/wheels/cf/77/af/aee8a9045795a9f737655f4c4db59b6b464829a35f3b2c10b2
Successfully built ordereddict
Installing collected packages: ordereddict
Successfully installed ordereddict-1.1

That gives room to the suspicion that the conflict report has to do with the fact that the package in question uses a linear versioning scheme (i.e. just an integer version M).

Expected behavior

The above constraints and requirements for packages with a linear versioning scheme should not cause a conflict.

pip version

21.3.1

Python version

3.10, 3.9

OS

macOS, Windows

How to Reproduce

  1. Have the minimum-constraints.txt and requirements.txt file described above
  2. Run pip install -c minimum-constraints.txt -r requirements.txt

Output

See above

Code of Conduct

andy-maier avatar Dec 03 '21 06:12 andy-maier

So if I understand correctly, pip is correct that this should not install (because version 227 does not have a 3.10 wheel nor a source distribution), but the error message it emits is confusing.

uranusjr avatar Dec 04 '21 14:12 uranusjr

Sorry for the delay. I agree that pip should not install version 227 on Python 3.10 due to unavailability of a package for 3.10. In fact, I did not notice that when I opened the issue, I got hung up on the seemingly irrational reasoning in the message. Sorry for that.

andy-maier avatar Sep 05 '22 21:09 andy-maier

@andy-maier Could you please avoid mentioning the isusue in a commit message, in the future (at least, for pip issues)? Most of this issue event log is rebases of the same commit.

pradyunsg avatar Sep 05 '22 21:09 pradyunsg

@pradyunsg Sure, if it helps. I was not aware that it causes all these entries here in the PR.

andy-maier avatar Dec 22 '22 16:12 andy-maier

That error message is indeed quite confusing. I had the same problem here:

$ echo typing-extensions==4.5.0 >constraint.txt
$ pip install typing-extensions==4.5.0 --constraint constraint.txt --index-url https://download.pytorch.org/whl/cu117

Looking in indexes: https://download.pytorch.org/whl/cu117
ERROR: Cannot install typing-extensions==4.5.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested typing-extensions==4.5.0
    The user requested (constraint) typing-extensions==4.5.0

There is no conflict; that version does not exist (on that index anymore).

petsuter avatar Sep 19 '23 16:09 petsuter

Just ran into this, and boy, is this a confusing error message for what the actual problem was, which was a missing intel-flavored wheel for the sentry-relay version requested in the lockfile.

ERROR: Cannot install sentry-relay==0.8.60 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested sentry-relay==0.8.60
    The user requested (constraint) sentry-relay==0.8.60

It would be great if this could be fixed - would have saved me at least half an hour just now.

(This is with pip 23.3.1)

lobsterkatie avatar May 07 '24 21:05 lobsterkatie