Python — PIP
The package installer
The standard library is huge, but PyPI hosts 500,000+ community packages:
pip install requests
That's it — the package downloads and becomes importable:
import requests
r = requests.get("https://api.github.com")
r.status_code
Everyday commands
pip install requests # install latest
pip install "requests==2.31" # exact version
pip install --upgrade requests
pip uninstall requests
pip list # what's installed
pip show requests # version, location, dependencies
requirements.txt — reproducible projects
Freeze exactly what your project needs:
pip freeze > requirements.txt # snapshot current environment
# requirements.txt
requests==2.31.0
pandas==2.2.0
flask>=3.0
Anyone (including future-you) rebuilds it:
pip install -r requirements.txt
Virtual environments — non-negotiable hygiene
Global installs eventually collide: project A needs pandas 1.x, project B needs 2.x. Virtual envs give each project its own isolated set:
python -m venv .venv # create
# activate:
.venv\Scripts\activate # Windows PowerShell
source .venv/bin/activate # mac/linux
pip install requests # installs ONLY inside .venv
deactivate # exit when done
Your prompt shows (.venv) while active. Delete the folder to reset completely.
Rule: never
pip installinto the system Python. One venv per project, always.
Popular first packages
| Package | Superpower |
|---|---|
| requests | humane HTTP calls |
| pandas | data tables & analysis |
| flask / fastapi | web servers |
| pillow | image processing |
| pytest | testing |
Finding good packages
- Search pypi.org
- Check: recent release date · download counts · docs quality
- Prefer well-maintained over clever-and-abandoned
Troubleshooting quick hits
'pip' is not recognized→ usepython -m pip install …- Permission errors → you're outside a venv; make one
- Slow builds → some packages compile C; wheels usually prebuilt on common platforms
Mini Practice
- Create + activate a venv; confirm prompt change.
- Install requests; verify with pip show.
- Freeze requirements.txt; delete and reinstall from it.
- Deactivate; prove the package vanished from global scope.
- Install one new-to-you package and print its version in Python.
Next: try/except →
Related Topics
Frequently Asked Questions about PIP
What is PIP in Python?
PIP is a fundamental concept in Python. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn PIP?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn PIP.
Why is PIP important in Python?
PIP is essential for Python development. Understanding this concept will help you write better code and solve real-world problems more effectively.