pip and Packages Beyond the Standard Library
The standard library is huge, but the true power of Python is PyPI — the Python Package Index — with over 500,000 free packages. One command installs almost any capability: web frameworks, AI libraries, PDF tools, you name it.
pip — your package manager
pip is Python's installer (it ships with Python). The essential commands:
pip install package-name # install
pip install package-name==2.1.0 # install a SPECIFIC version
pip install --upgrade package-name # update
pip uninstall package-name # remove
pip list # what's installed
pip show package-name # details about one packageInstall something real — the requests library (next lesson's star):
pip install requestsThen import it like the standard library:
import requests
print(requests.__version__)One command, one import — that's the entire deal. This is why Python dominates: whatever you're building, someone probably published the hard parts already.
Always inside a virtual environment
Module 2 taught venvs — this is where they matter most:
# the ritual for every new project
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install requests pandasWithout a venv, every package lands in one global pile — version conflicts between projects are inevitable. With a venv, each project owns its packages. Install globally = future chaos. Install in a venv = future calm.
requirements.txt — your project's recipe
Freeze what you've installed so anyone (including future you, including deployment servers) can recreate the exact environment:
pip freeze > requirements.txtThe file looks like:
requests==2.31.0
streamlit==1.41.1
pandas==2.2.3Recreating the environment anywhere:
pip install -r requirements.txtThis two-file pair (code + requirements.txt) is what makes projects portable — and it's exactly what the Streamlit Cloud deployment in your other course requires.
Finding packages — how to choose
When you need a capability, search PyPI.org or ask: "python how to [task]". With thousands of options, pick by:
The famous ones you'll meet on your journey:
| Package | Superpower |
|---|---|
requests | HTTP/API calls |
pandas | data analysis |
streamlit | web apps from Python |
numpy | fast number crunching |
matplotlib | charts |
beautifulsoup4 | web scraping |
openai / mistralai | AI APIs |
Common Errors & Fixes
python -m pip install ... (runs pip through your Python, always works).which python and which pip point to the same venv.sudo pip).✅ Checkpoint
pip: command not found — what always works? *(python -m pip install ...)*Next: requests — your code's passport to the internet.