pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.49k stars 3.01k forks source link

Unclear error message when requirements conflict #8361

Open astrofrog opened 4 years ago

astrofrog commented 4 years ago

I am testing out the resolver in pip 20.2b and found that while it is able to identify conflicts/incompatible versions, the error message even for simple cases is not very clear - as an example:

% pip install "numpy<1.16" "astropy>4.0"
Collecting astropy>4.0
  Downloading astropy-4.0.1.post1-cp38-cp38-macosx_10_9_x86_64.whl (6.5 MB)
     |████████████████████████████████| 6.5 MB 13.5 MB/s 
Collecting astropy>4.0
  Downloading astropy-4.0.1-cp38-cp38-macosx_10_9_x86_64.whl (6.5 MB)
     |████████████████████████████████| 6.5 MB 2.8 MB/s 
ERROR: Could not find a version that satisfies the requirement numpy<1.16
ERROR: Could not find a version that satisfies the requirement numpy>=1.16 (from astropy)
ERROR: Could not find a version that satisfies the requirement numpy<1.16
ERROR: Could not find a version that satisfies the requirement numpy>=1.16 (from astropy)
ERROR: No matching distribution found for numpy, numpy, numpy, numpy

Astropy 4.0 requires Numpy >=1.16, so specifying explicitly numpy<1.16 leads to an error (as it should) - but the error message is not very clear (especially the last line which complains about numpy four times). As a user, I would ideally expect to see an error message along the lines of 'astropy>4.0' requires numpy>=1.16 which is incompatible with 'numpy<1.16' or something like this.

To be clear, in this situation the resolver is working fine, and in a case such as the following it does find combinations that work:

en% pip install "numpy<1.15" "astropy>3.0"
Collecting astropy>3.0
  Using cached astropy-4.0.1.post1-cp38-cp38-macosx_10_9_x86_64.whl (6.5 MB)
Collecting astropy>3.0
  Using cached astropy-4.0.1-cp38-cp38-macosx_10_9_x86_64.whl (6.5 MB)
Collecting astropy>3.0
  Downloading astropy-4.0-cp38-cp38-macosx_10_9_x86_64.whl (6.5 MB)
     |████████████████████████████████| 6.5 MB 9.4 MB/s 
Collecting astropy>3.0
  Downloading astropy-3.2.3-cp38-cp38-macosx_10_9_x86_64.whl (6.3 MB)
     |████████████████████████████████| 6.3 MB 7.1 MB/s 
Collecting numpy<1.15
  Downloading numpy-1.14.6.zip (4.9 MB)
     |████████████████████████████████| 4.9 MB 6.0 MB/s 
Using legacy setup.py install for numpy, since package 'wheel' is not installed.
Installing collected packages: numpy, astropy

So this issue is mainly to request more readable error output for cases where it doesn't work (to avoid the issue of conda resolution conflict logs which are unparsable by users).

pfmoore commented 4 years ago

Thanks for the report. We're actively looking at how to improve the error messages, and user feedback is really important in this exercise. So could I ask, what would have been helpful to include in the error in this case? If you can describe the key pieces of information you would have liked to see, that would be a great help. Or if you could give an example of the error you would have liked pip to display in this case, that would be really useful as well.

astrofrog commented 4 years ago

What would be important for me would be to know in this specific case is which of the things I specified explicitly had conflicts. For instance if I had done pip install "numpy<1.16" "astropy>4.0" scipy matplotlib I would want the error message to be:

ERROR: 'astropy>4.0' requires numpy>=1.16 which is incompatible with 'numpy<1.16'

(that is, the error message should ideally include somewhere the original package requirements I typed). I realize this won't cover all cases of course, but this is just the information that is important to me in this case.

pfmoore commented 4 years ago

Thanks, that's useful to know. We can look at how to present that information in the error.

DiddiLeija commented 3 years ago

HI! How is this issue going? Have we fixed it on a newer version of pip? Can we close it?