Misleading error does not distinguish between missing dependency vs dependency conflict
Description
Pip gives the error "Cannot install XYZ because these package versions have conflicting dependencies" when there is no dependency conflict.
I set up a PEP-503-compliant repo on artifactory, and published a few versions of my package my-py-package.
I then ran the command
python -m pip install --index-url "https://cowlinator:[REDACTED]@artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/simple" my-py-package
which resulted in the following error:
ERROR: Cannot install my-py-package==0.1.2rc0, my-py-package==0.1.2rc1 and my-py-package==0.1.2rc3 because these package versions have conflicting dependencies.
The conflict is caused by:
my-py-package 0.1.2rc3 depends on keyrings.cryptfile>=1.3.3
my-py-package 0.1.2rc1 depends on keyrings.cryptfile>=1.3.3
my-py-package 0.1.2rc0 depends on keyrings.cryptfile>=1.3.3
It's obvious to see that pip is reporting a dependency conflict when no conflict exists, but it's not easy to understand why. Eventually, I discovered that this error occurs because the repo does not contain the keyrings package.
Running the command
python -m pip install --extra-index-url "https://cowlinator:[REDACTED]@artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/simple" my-py-package
Succeeds as expected.
Expected behavior
The pip error should not state that a dependency conflict exists.
Also, the error should state that the dependency package cannot be found on the repo(s).
pip version
22.0.4
Python version
3.10.0
OS
Windows 10 (20H2)
How to Reproduce
- Create a PEP-503-compliant repo.
- Create a python package that has 1 or more dependencies from pypi.org
- Upload that package to your repo.
- Clear your pip cache
- run
python -m pip install --index-url "<your_repo_url>" <your-package-name>
Output
(venv) D:\Dev\sandbox\piptest1>python -m pip install --index-url "https://cowlinator:[REDACTED]@artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/simple" my-py-package
Looking in indexes: https://cowlinator:****@artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/simple
Collecting swp-autoupdate
Using cached https://artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/my-py-package/0.1.2rc3/my-py-package-0.1.2rc3-py2.py3-none-any.whl (34 kB)
Using cached https://artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/my-py-package/0.1.2rc1/my-py-package-0.1.2rc1-py2.py3-none-any.whl (34 kB)
Using cached https://artifactory.[REDACTED].com/artifactory/api/pypi/my-pep503-repo/my-py-package/0.1.2rc0/my-py-package-0.1.2rc0-py2.py3-none-any.whl (34 kB)
ERROR: Cannot install my-py-package==0.1.2rc0, my-py-package==0.1.2rc1 and my-py-package==0.1.2rc3 because these package versions have conflicting dependencies.
The conflict is caused by:
my-py-package 0.1.2rc3 depends on keyrings.cryptfile>=1.3.3
my-py-package 0.1.2rc1 depends on keyrings.cryptfile>=1.3.3
my-py-package 0.1.2rc0 depends on keyrings.cryptfile>=1.3.3
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/topics/dependency-resolution/#dealing-with-dependency-conflicts
Code of Conduct
- [X] I agree to follow the PSF Code of Conduct.
Another variant of this seems to be:
minimum-constraints.txt file:
ansible==5.0.0
requirements.txt file:
ansible>=5.0.0
Pip error:
$ pip install -r requirements.txt -c minimum-constraints.txt
ERROR: Cannot install ansible>=5.0.0 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested ansible>=5.0.0
The user requested (constraint) ansible==5.0.0
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/topics/dependency-resolution/#dealing-with-dependency-conflicts
This was with pip 22.3.1 on Python 3.10.
Reason for this is that there is no ansible 5.0.0 package on Pypi (it starts with 5.0.1).
The issue is that the error message is confusing. Reporting the missing package version should have precedence over reporting a conflict where there is none.
Thanks @cowlinator and @andy-maier for the reproducers.
This is definitely a bug -- likely related to how "no remaining candidates" is treated by the resolver as a situation triggered by unresolvable dependencies -- which can look the same as with no candidates being found for a package that does not exist.
Did we solve this issue?
I met the same one .
Python 3.10 Pip 25.0.1
11:43:08 The conflict is caused by:
11:43:08 apache-airflow 2.10.5 depends on flask-wtf>=1.1.0
11:43:08 The user requested (constraint) flask-wtf==1.2.2
11:43:08
11:43:08 To fix this you could try to:
11:43:08 1. loosen the range of package versions you've specified
11:43:08 2. remove package versions to allow pip to attempt to solve the dependency conflict
Did we solve this issue?
I met the same one .
Python 3.10 Pip 25.0.1
Several dependency and resolver fixes went in in pip 25.1, can you try upgrading pip and see if you get the same unusual error.
Did we solve this issue? I met the same one . Python 3.10 Pip 25.0.1
Several dependency and resolver fixes went in in pip 25.1, can you try upgrading pip and see if you get the same unusual error.
python3 -m pip install --upgrade pip==25.1.1
Met this one in ubuntu, what should I do? @notatallshaw
11:36:54 update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
11:36:56 [91mERROR: Could not find a version that satisfies the requirement pip==25.1.1 (from versions: 0.2, 0.2.1, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.8.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.2, 1.2.1, 1.3, 1.3.1, 1.4, 1.4.1, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.1.0, 6.1.1, 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.1.0, 8.1.1, 8.1.2, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 10.0.0b1, 10.0.0b2, 10.0.0, 10.0.1, 18.0, 18.1, 19.0, 19.0.1, 19.0.2, 19.0.3, 19.1, 19.1.1, 19.2, 19.2.1, 19.2.2, 19.2.3, 19.3, 19.3.1, 20.0, 20.0.1, 20.0.2, 20.1b1, 20.1, 20.1.1, 20.2b1, 20.2, 20.2.1, 20.2.2, 20.2.3, 20.2.4, 20.3b1, 20.3, 20.3.1, 20.3.2, 20.3.3, 20.3.4, 21.0, 21.0.1, 21.1, 21.1.1, 21.1.2, 21.1.3, 21.2, 21.2.1, 21.2.2, 21.2.3, 21.2.4, 21.3, 21.3.1, 22.0, 22.0.1, 22.0.2, 22.0.3, 22.0.4, 22.1b1, 22.1, 22.1.1, 22.1.2, 22.2, 22.2.1, 22.2.2, 22.3, 22.3.1, 23.0, 23.0.1, 23.1, 23.1.1, 23.1.2, 23.2, 23.2.1, 23.3, 23.3.1, 23.3.2, 24.0, 24.1b1, 24.1b2, 24.1, 24.1.1, 24.1.2, 24.2, 24.3, 24.3.1, 25.0, 25.0.1)
11:36:56 [0m[91mERROR: No matching distribution found for pip==25.1.1
python3 -m pip install --upgrade pip==25.1.1
Met this one in ubuntu, what should I do? @notatallshaw
What does python3 -V give you? If it says Python 3.8 you're running pip upgrade in the wrong environment.