pip install <package> # Example: pip install pandas # Example: pip install requests
5 Simple Steps to Install a Library in Python
Follow this 5 step procedure to install a library, module, or package in Python:
- Download Python if you haven’t already and install it in your environment.
- Add the
python
orpip
commands to your environment variable so you can access them from the command line (Win) or terminal (macOS, Linux). - After Python is installed, run the following PIP command in your shell/terminal/cmd: python -m pip install xxx. Replace
xxx
with your library name (e.g.,python -m pip install pandas
to install pandas). - This may fail for various reasons. To work around those, try either
pip install xxx
,pip3 install xxx
, orpython3 -m pip install xxx
. If none works, go back to step 2. - Verify the library
xxx
is installed using the commandpip list
orpip3 list
, or the Python expressionimport xxx; print(xxx.__version__)
. Of course, replacexxx
with your library name (e.g.,pandas
orrequests
).
Related Tutorials
If you run into the ModuleNotFoundError
, check out our full guide on how to resolve it here:
π Recommended Tutorial: ModuleNotFoundError: No module named βxxxβ
If you want to check the package version, check out our full guide on this here:
π Recommended Tutorial: 8 Best Ways to Check the Package Version in Python
Do you want to install a specific package or module version? Try this tutorial:
π Recommended Tutorial: Installing Specific Package Versions With PIP
Do you have a wheel (.whl
) file to install the Python package? Check out this tutorial on the Finxter blog!
π Recommended Tutorial: How to Install a Python Package with a .whl File?
Finally, are you on PyCharm? Use this simple approach to install a package there:
π Recommended Tutorial: How to Install a Library on PyCharm?
Thanks for visiting our site! Feel free to come back more by subscribing to our free learning community:
We have cheat sheets! π
Programming Humor
π‘ Programming is 10% science, 20% ingenuity, and 70% getting the ingenuity to work with the science.
~~~
- Question: Why do Java programmers wear glasses?
- Answer: Because they cannot C# …!
Feel free to check out our blog article with more coding jokes. π

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.