pip and Installing Libraries
pip and Installing Libraries
Python has many built-in modules.
But sometimes you need tools created by other developers.
You can install them with pip.
What Is pip?
pip is Python’s package manager.
It helps you:
- install libraries
- update libraries
- remove libraries
A library is extra code you can use in your projects.
Why This Matters
With pip, you can use powerful tools for:
- web requests
- data analysis
- web apps
- automation
- games
- machine learning
Check pip
In the terminal, run:
pip --version
Install a Library
Example: install Requests
pip install requests
Use the Library
import requests
Install Specific Version
pip install requests==2.31.0
Upgrade a Library
pip install --upgrade requests
Remove a Library
pip uninstall requests
See Installed Libraries
pip list
Another Popular Libraries
- Flask - web apps
- Pandas - data tables
- NumPy - arrays
- Matplotlib - charts
Common Beginner Errors
pip Not Found
Try:
python -m pip --version
Wrong Python Version
Some computers have multiple Python versions.
Try:
python -m pip install requests
No Internet
Installing packages needs internet access.
Code Along
Install requests.
Then import it in Python.
Mini Challenge
Tasks:
- Check pip version
- Install
requests - Show installed packages
Expected terminal example:
requests 2.x.x
Real World Use Case
Developers use pip to install tools for websites, APIs, data science, automation, and testing.
Quiz
- What is
pip? - What command installs a package?
- How do you remove a package?
- Why are external libraries useful?
Assignment
Install one Python library, import it, and write one line about what it is used for.
Summary
You learned how to use pip to install, upgrade, list, and remove Python libraries.