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

Resolver error on package version change #2114

Open
ianrandman opened this issue Jul 16, 2024 · 5 comments
Open

Resolver error on package version change #2114

ianrandman opened this issue Jul 16, 2024 · 5 comments

Comments

@ianrandman
Copy link

ianrandman commented Jul 16, 2024

Related issue: #1977

When changing the version of a pinned dependency in requirements.in with an existing requirements.txt that includes an unpinned dependency that must change, pip-compile fails with a resolver error.

Environment Versions

  1. Windows 11
  2. Python 3.10.13
  3. pip 23.3.1
  4. pip-compile, version 7.4.1

Steps to replicate

$ rm -f requirements.in requirements.txt 

$ echo $'torch==2.2.2\ntorchvision' > requirements.in

$ pip-compile -q

$ grep 'torchvision' requirements.txt
    # via torchvision
    # via torchvision
    #   torchvision
torchvision==0.17.2

$ echo $'torch==2.3.1\ntorchvision' > requirements.in

$ pip-compile -q
  ERROR: Cannot install -r requirements.in (line 2) and torch==2.3.1 because these package versions have conflicting dependencies.
...
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('torch==2.3.1'), parent=None), RequirementInformation(requirement=SpecifierRequirement('torch==2.2.2'), parent=LinkCandidate('https://files.pythonhosted.org/packages/0a/b8/027b3c36e61a26d14d4e9a8413d4a09e5fd8d3e01e3efce78447ca1dc3dd/torchvision-0.17.2-cp310-cp310-win_amd64.whl (from https://pypi.org/simple/torchvision/) (requires-python:>=3.8)'))]
...
pip._internal.exceptions.DistributionNotFound: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

$ rm requirements.txt 

$ pip-compile -q

$ grep 'torchvision' requirements.txt
    # via torchvision
    # via torchvision
    #   torchvision
torchvision==0.18.1

Expected result

Running pip-compile with the changed version for torch will automatically change the torchvision version to satisfy requirements.in instead of failing.

@webknjaz
Copy link
Member

Could you include full file contents, not just parts of them?

@ianrandman
Copy link
Author

Could you include full file contents, not just parts of them?

$ rm -f requirements.in requirements.txt 

$ echo $'torch==2.2.2\ntorchvision' > requirements.in

$ pip-compile -q
WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.

$ cat requirements.txt
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile
#
filelock==3.15.4
    # via torch
fsspec==2024.6.1
    # via torch
jinja2==3.1.4
    # via torch
markupsafe==2.1.5
    # via jinja2
mpmath==1.3.0
    # via sympy
networkx==3.3
    # via torch
numpy==2.0.0
    # via torchvision
pillow==10.4.0
    # via torchvision
sympy==1.13.0
    # via torch
torch==2.2.2
    # via
    #   -r requirements.in
    #   torchvision
torchvision==0.17.2
    # via -r requirements.in
typing-extensions==4.12.2
    # via torch

$ echo $'torch==2.3.1\ntorchvision' > requirements.in

$ pip-compile -q
  ERROR: Cannot install -r requirements.in (line 2) and torch==2.3.1 because these package versions have conflicting dependencies.
...
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('torch==2.3.1'), parent=None), RequirementInformation(requirement=SpecifierRequirement('torch==2.2.2'), parent=LinkCandidate('https://files.pythonhosted.org/packages/0a/b8/027b3c36e61a26d14d4e9a8413d4a09e5fd8d3e01e3efce78447ca1dc3dd/torchvision-0.17.2-cp310-cp310-win_amd64.whl (from https://pypi.org/simple/torchvision/) (requires-python:>=3.8)'))]
...
pip._internal.exceptions.DistributionNotFound: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

$ rm requirements.txt 

$ pip-compile -q
WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.

$ cat requirements.txt
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile
#
filelock==3.15.4
    # via torch
fsspec==2024.6.1
    # via torch
intel-openmp==2021.4.0
    # via mkl
jinja2==3.1.4
    # via torch
markupsafe==2.1.5
    # via jinja2
mkl==2021.4.0
    # via torch
mpmath==1.3.0
    # via sympy
networkx==3.3
    # via torch
numpy==2.0.0
    # via torchvision
pillow==10.4.0
    # via torchvision
sympy==1.13.0
    # via torch
tbb==2021.13.0
    # via mkl
torch==2.3.1
    # via
    #   -r requirements.in
    #   torchvision
torchvision==0.18.1
    # via -r requirements.in
typing-extensions==4.12.2
    # via torch

@webknjaz
Copy link
Member

Does using --upgrade help?

@ianrandman
Copy link
Author

Does using --upgrade help?

Yes, but I do not want to upgrade packages unless necessary. My understanding is the same as in #1977 (comment). My intention is to maintain existing constraints when possible and only drop them if need be, which I believe is the intended behavior of pip-compile without --upgrade.

@ianrandman
Copy link
Author

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants