pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

pipenv should inform about Python version mismatch

Open ThomasSteinbach opened this issue 3 years ago • 1 comments

If a dependency requires a newer Python version than configured in the current Pipfile, then pipenv fails to install the depencencys - which is totally fine - but didn't give a reason why the installation failed. Here an example of the pipenv output:

thomass@bwpm-G3MW424H6N cdk-base-stacks % pipenv install --dev
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 

CRITICAL:pipenv.patched.pip._internal.resolution.resolvelib.factory:Cannot install -r /var/folders/6p/p41kzv952szcvs_h3hnk9fz40000gn/T/pipenvr0fs9l8crequirements/pipenv-xon0274m-constraints.txt (line 4) because these package versions have conflicting dependencies.
[ResolutionFailure]:   File "/Users/thomass/Library/Python/3.8/lib/python/site-packages/pipenv/resolver.py", line 821, in _main
[ResolutionFailure]:       pre, clear, verbose, system, write, requirements_dir, packages, dev
[ResolutionFailure]:   File "/Users/thomass/Library/Python/3.8/lib/python/site-packages/pipenv/resolver.py", line 776, in resolve_packages
[ResolutionFailure]:       requirements_dir=requirements_dir,
[ResolutionFailure]:   File "/Users/thomass/Library/Python/3.8/lib/python/site-packages/pipenv/resolver.py", line 757, in resolve
[ResolutionFailure]:       req_dir=requirements_dir,
[ResolutionFailure]:   File "/Users/thomass/Library/Python/3.8/lib/python/site-packages/pipenv/utils/resolver.py", line 1097, in resolve_deps
[ResolutionFailure]:       req_dir=req_dir,
[ResolutionFailure]:   File "/Users/thomass/Library/Python/3.8/lib/python/site-packages/pipenv/utils/resolver.py", line 883, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/Users/thomass/Library/Python/3.8/lib/python/site-packages/pipenv/utils/resolver.py", line 688, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

It would be really nice if pipenv would detect, that the Python version of the current project is too low for the dependencies and print out that information. Otherwise it is really difficult - or even luck to figure that out.

ThomasSteinbach avatar Aug 11 '22 07:08 ThomasSteinbach

@ThomasSteinbach This is probably a non-trivial enhancement request -- we are essentially relying on the pip resolver to resolve packages that match the markers from the Pipfile -- in this case resolution was impossible. It would be hard to know the reason resolution was not possible is because of a general version mismatch vs a new version does exist but isn't compatible with your python marker.

matteius avatar Aug 12 '22 19:08 matteius

Hi, I think this might be a regression bug. Check version 2021.5.29 in which the error is well specified:

[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Could not find a version that matches python-dateutil<3.0.0,==2.8.0,>=2.1,>=2.7.3,>=2.8.2 (from another-lib==1.410.1->-r /tmp/pipenv2wkd7kbxrequirements/pipenv-ngop3m2d-constraints.txt (line 5))
Tried: 1.4, 1.4.1, 1.5, 2.1, 2.2, 2.3, 2.3, 2.4.0, 2.4.0, 2.4.1, 2.4.1, 2.4.1.post1, 2.4.1.post1, 2.4.2, 2.4.2, 2.5.0, 2.5.0, 2.5.0, 2.5.1, 2.5.1, 2.5.1, 2.5.2, 2.5.2, 2.5.2, 2.5.3, 2.5.3, 2.5.3, 2.6.0, 2.6.0, 2.6.0, 2.6.1, 2.6.1, 2.7.0, 2.7.0, 2.7.1, 2.7.1, 2.7.2, 2.7.2, 2.7.3, 2.7.3, 2.7.4, 2.7.4, 2.7.5, 2.7.5, 2.8.0, 2.8.0, 2.8.1, 2.8.1, 2.8.2, 2.8.2
There are incompatible versions in the resolved dependencies:
  python-dateutil<3.0.0,>=2.1 (from botocore==1.24.21->my-library==1.0.0->-r /tmp/pipenv2wkd7kbxrequirements/pipenv-ngop3m2d-constraints.txt (line 7))
  python-dateutil<3.0.0,>=2.8.2 (from another-lib==1.410.1->-r /tmp/pipenv2wkd7kbxrequirements/pipenv-ngop3m2d-constraints.txt (line 5))
  python-dateutil==2.8.0 (from ml-pipeline-utils==1.0->my-library==1.0.0->-r /tmp/pipenv2wkd7kbxrequirements/pipenv-ngop3m2d-constraints.txt (line 7))
  python-dateutil>=2.7.3 (from pandas==1.3.0->my-library==1.0.0->-r /tmp/pipenv2wkd7kbxrequirements/pipenv-ngop3m2d-constraints.txt (line 7))

sireliah avatar Nov 03 '22 15:11 sireliah

I believe you get this level of output with the -v or --verbose flag in recent releases.

matteius avatar Sep 12 '23 12:09 matteius

I don't understand why this issue was closed, it is a clear regression. I do not get the desired output when running with verbose mode.

Just the fact that dependency mismatch makes pipenv print an exception and a stack trace is a strong sign that it does not handle this correctly anymore. It used to just print out what was wrong and exit gracefully as @sireliah showed.

fraghag avatar Jan 11 '24 15:01 fraghag