pyproject.tomlModern Python package management relies on isolated virtual environments (venv) and standard pyproject.toml project manifests. Isolating each project prevents a library upgrade in Project A from breaking dependencies in Project B.
Python's built-in venv module creates an isolated folder holding its own Python binary and site-packages directory with zero extra tools required.
Create the environment inside your project root (conventionally named .venv), activate it in your shell, and install packages safely inside it.
# Create virtual environment
python -m venv .venv
# Activate on Windows PowerShell
.venv\Scripts\Activate.ps1
# Activate on macOS / Linux
source .venv/bin/activate
# Install inside the isolated environment
python -m pip install fastapi uvicorn
Once activated, your terminal prompt shows (.venv) and python resolves directly to .venv.
pyproject.tomlModern Python projects follow PEP 621 and declare metadata and dependencies inside pyproject.toml rather than legacy setup.py scripts.
[project]
name = "invoice-cli"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
"httpx>=0.27,<1.0",
"pydantic>=2.8",
]
.venv/ to Git: Virtual environments contain thousands of platform-specific binaries; always add .venv/ to .gitignore..venv: Check which python (or Get-Command python on Windows) if an import fails right after pip install.pip freeze > requirements.lock so production deploys install tested exact versions..whl) file?A Wheel is a pre-built binary package archive that pip extracts directly into site-packages in seconds, avoiding slow C compilation during installation.
Type deactivate in your terminal to restore your default system shell path.
venv, pipx, and uv differ?venv isolates project libraries, pipx installs global CLI apps (like black or ruff) in separate sandboxes, and uv is a fast Rust-based replacement for pip and venv.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.