💬 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
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.”
🌍 “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! 🙂
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.