Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between constraint in requirements.txt and separate constraints file raises unhelpful error #9448

Closed
stephenfin opened this issue Jan 13, 2021 · 1 comment
Labels
resolution: no action When the resolution is to not do anything

Comments

@stephenfin
Copy link

stephenfin commented Jan 13, 2021

What did you want to do?

Consider the following requirements.txt and constraints.txt files:

$ cat requirements.txt 
requests>=2.20.0,<2.25.0
$ cat constraints.txt 
requests==2.25.0

You'll note that I'm saying the upper cap should be <2.25.0 in requirements.txt and that it should be ==2.25.0 in constraints.txt. This fails, which does seem reasonable given this is most likely a bug/misconfiguration. However, the error message is not clear and enabling verbose mode doesn't provide any further hints. When there are many requirements and constraints, it can be difficult to identify the root cause.

Output

$ pip install -c constraints.txt -r requirements.txt 
ERROR: Could not find a version that satisfies the requirement requests<2.25.0,>=2.20.0
ERROR: No matching distribution found for requests<2.25.0,>=2.20.0

I expected either the command to fail with a more helpful error message (e.g. There are conflicting constraints for the requirement requests) or for pip to configure the allowed range of requirements to the minimal combined range of all requirements and constraints files.

Additional information

I also tried this using the current master commit. Same issue.

@pradyunsg pradyunsg added the resolution: no action When the resolution is to not do anything label Mar 6, 2021
@pradyunsg
Copy link
Member

#9300 fixed this.

(old)

pip install -c c.txt -r r.txt
ERROR: Could not find a version that satisfies the requirement requests<2.25.0,>=2.20.0
ERROR: No matching distribution found for requests<2.25.0,>=2.20.0

(current master)

pip install https://github.com/pypa/pip/archive/master.zip
Collecting https://github.com/pypa/pip/archive/master.zip
  Downloading https://github.com/pypa/pip/archive/master.zip
     - 9.1 MB 1.0 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: pip
  Building wheel for pip (PEP 517) ... done
  Created wheel for pip: filename=pip-21.1.dev0-py3-none-any.whl size=1527251 sha256=be7f25a24d8c1d44d168e9dde7b602e14e5d20f6880b33ac455d56cf1afaa039
  Stored in directory: /private/var/folders/4d/bt0_xfx56bjfmmt2bv3r5_qh0000gn/T/pip-ephem-wheel-cache-h4ll96js/wheels/b2/f0/ae/286fb76d950bd0a0d20bcabbda0f56531389ed5030f038f6b9
Successfully built pip
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.0.1
    Uninstalling pip-21.0.1:
      Successfully uninstalled pip-21.0.1
Successfully installed pip-21.1.dev0pip install -c c.txt -r r.txt                             
ERROR: Cannot install requests<2.25.0 and >=2.20.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested requests<2.25.0 and >=2.20.0
    The user requested (constraint) requests==2.25.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/user_guide/#fixing-conflicting-dependencies

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: no action When the resolution is to not do anything
Projects
None yet
Development

No branches or pull requests

2 participants