pypa / pip

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

Present more informative `no distributions found` error when attempting to install a stdlib module #12731

Open ichard26 opened 1 month ago

ichard26 commented 1 month ago

What's the problem this feature will solve?

Beginners to Python sometimes try to install standard library modules and end up confused when met with a no distributions found for XXX error.

Describe the solution you'd like

Ideally, pip would let the user know they're attempting to install a standard library module.

This would be helpful for situations where the user is simply unaware that the module is built-in, saving them the frustration of not being able to use the stdlib module (telling them "you don't need to install it, matter of fact!"). This wouldn't be that helpful when a stdlib module is missing (e.g. missing build dependencies or a Debian-style split-up Python install), but the error's associated write-up could potentially go into further detail.

Alternative Solutions

n/a

Additional context

One other problem is that sys.stdlib_module_names was only added in Python 3.10. Maintaining a separate list of standard library modules doesn't sound like a good use of our time, so this error could only exist on Python 3.10+.

Code of Conduct

pradyunsg commented 1 month ago

Sounds like a good idea to me -- labelling to reflect that the next step here is filing a PR.