Is PIP/PyPI Case Sensitive?

5/5 - (2 votes)

πŸ’¬ Question: When installing packages with pip, does it matter if the letters are capitalized (uppercase/lowercase), i.e., is PIP case sensitive?


PyPI and PIP are not case-sensitive. Instead, Python package names are case-insensitive. For example, it doesn’t matter whether you run pip install Pandas, pip install PANDAS, or pip install pandas.

However, Python package names are case sensitive when used within the Python code itself, e.g., import PANDAS and import Pandas will raise a ModuleNotFoundError whereas import pandas will work just fine.

Here’s this example:

>>> import PANDAS
Traceback (most recent call last):
  File "<pyshell#10>", line 1, in <module>
    import PANDAS
ModuleNotFoundError: No module named 'PANDAS'
>>> import Pandas
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    import Pandas
ModuleNotFoundError: No module named 'Pandas'
>>> import pandas


The case insensitivity is outlined in multiple official Python sources (PEP) such as here:

🌍 “PyPI places strict restrictions on names – they must match a case insensitive regex or they won’t be accepted.”

And here:

🌍 “All comparisons of distribution names MUST be case insensitive, and MUST consider hyphens and underscores to be equivalent.”

Thanks for reading this short tutorial. If you want to keep improving your Python skills, I’d love to see you in the Finxter email academy. It’s free and we have cheat sheets too! πŸ™‚