pip and Packages
pip and Packages
Section titled “pip and Packages”Simple Analogy 📦
Section titled “Simple Analogy 📦”Think of pip as a package delivery service for Python. You want requests (a package) — you tell pip, and it fetches it from the PyPI warehouse (Python Package Index), unpacks it, and puts it where Python can find it.
What is pip?
Section titled “What is pip?”pip = Pip Installs Packages. It’s Python’s standard package manager, included with Python 3.4+.
# Check if pip is installedpip --version# pip 25.0 from ... (.venv)
# Get helppip helpCommon pip Commands
Section titled “Common pip Commands”# Install a packagepip install requests
# Install a specific versionpip install flask==3.1.0
# Install with minimum versionpip install "flask>=3.0"
# Install multiple packagespip install requests flask pandas
# Install from requirements filepip install -r requirements.txt
# Upgrade a packagepip install --upgrade pip
# Uninstallpip uninstall requests
# List installed packagespip list
# Show package detailspip show flask
# Search for packages (web only now)# https://pypi.org/search/Where Packages Live
Section titled “Where Packages Live”# Find where pip installs packagespip show requests# The site-packages folder is inside your virtual environmentProject Folder└── .venv/ ← Virtual environment ├── bin/ ← Executables (python, pip) ├── lib/ │ └── python3.12/ │ └── site-packages/ ← All installed packages live here │ ├── requests/ │ ├── flask/ │ └── ... └── pyvenv.cfg ← Points to the Python versionrequirements.txt — The Dependency File
Section titled “requirements.txt — The Dependency File”flask==3.1.0requests>=2.32,<3pandas~=2.2.0gunicorn# Freeze exact versions of everything installedpip freeze > requirements.txt
# Example output:# Flask==3.1.0# Jinja2==3.1.6# MarkupSafe==3.0.2# Werkzeug==3.1.3# requests==2.32.3# gunicorn==23.0.0Version Specifiers
Section titled “Version Specifiers”| Specifier | Meaning | Example |
|---|---|---|
==3.1.0 | Exact version | flask==3.1.0 |
>=3.0 | Minimum version | requests>=2.32 |
<=4.0 | Maximum version | flask<=4.0 |
~=2.2.0 | Compatible release (≥2.2.0, <3.0) | pandas~=2.2.0 |
* | Any version | gunicorn (no constraint) |
Common Package Categories
Section titled “Common Package Categories”| Category | Popular Packages |
|---|---|
| Web | Flask, Django, FastAPI, aiohttp |
| Data | pandas, numpy, polars, matplotlib |
| HTTP | requests, httpx, httplib2 |
| Database | SQLAlchemy, psycopg2, asyncpg, pymongo |
| Testing | pytest, unittest, hypothesis, tox |
| Async | asyncio, aiofiles, anyio |
| CLI | click, typer, argparse (built-in) |
🧠 In Simple Words
Section titled “🧠 In Simple Words”- pip = Python’s package installer — gets packages from PyPI (the official warehouse)
- Always activate your virtual environment before using pip
pip freeze > requirements.txtsaves your project’s dependencies so others can replicate itpip install -r requirements.txtinstalls everything from that file- Packages install into
.venv/lib/python3.x/site-packages/ - Use version specifiers (
==,>=,~=) to control which versions you get