pip icon indicating copy to clipboard operation
pip copied to clipboard

Show the detailed error when facing invalid requirements

Open sbidoul opened this issue 1 year ago • 6 comments

Description

From https://github.com/pypa/pip/issues/12691#issuecomment-2120014310

pip install --dry-run "python-hdf4>=0.10.0+dummy" prints ERROR: Invalid requirement: 'python-hdf4>=0.10.0+dummy'.

Expected behavior

The detailed, more informative error should be printed:

InvalidRequirement: Local version label can only be used with `==` or `!=` operators
    python-hdf4>=0.10.0+dummy
               ~~~~~~~~^

pip version

24.1b1

Python version

any

OS

any

How to Reproduce

pip install --dry-run "python-hdf4>=0.10.0+dummy"

Output

No response

Code of Conduct

sbidoul avatar May 20 '24 09:05 sbidoul

@stonebig as for a solution, you'll need to update the requirement to not include the +dummy part.

sbidoul avatar May 20 '24 09:05 sbidoul

I did it. I had the precise error message with the position. Just reported the "+" no more tolerated in case it was to consider a bug

stonebig avatar May 20 '24 10:05 stonebig

so me puting only the first line of the error miss-leaded you. you may close this one

stonebig avatar May 20 '24 10:05 stonebig

@stonebig what command did you use precisely? Because when I tried, the pip install command above did not report the error details.

sbidoul avatar May 20 '24 10:05 sbidoul

... time to figure out I had temporarly fell back to pip-24.0. so with Pip-24.1b1, the method is

...WPy64-31300b1b\scripts>python -m pip install --pre  --no-index --trusted-host=None  --find-links=...\packages.srcreq -c ...\constraints.txt six

generating:

ERROR: Invalid requirement: 'python-hdf4>=0.10.0+dummy' (from line 437 of ...\constraints.txt)`

and no line below. you are right: I allucinated the "detailed" error message, I don't see it either

stonebig avatar May 20 '24 10:05 stonebig

Ok, thanks. I created #12715 to improve the error message.

sbidoul avatar May 20 '24 10:05 sbidoul