Python, pip & uv commands

Create virtual environments, install and freeze packages with pip, and use uv, the fast modern Python package manager.

11 commands

Create and activate a virtual environment

macOSLinux

Keeps this project’s packages separate from the system.

python3 -m venv .venv && source .venv/bin/activate

Create and activate a venv on Windows

WindowsPowerShell

If activation is blocked, run: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

python -m venv .venv; .venv\Scripts\Activate.ps1

Install from requirements.txt

macOSWindowsLinux

Installs every package listed.

pip install -r requirements.txt

Save installed packages

macOSWindowsLinux

Writes exact versions of everything in the environment.

pip freeze > requirements.txt

Upgrade pip

macOSWindowsLinux

Use python instead of python3 on Windows.

python3 -m pip install --upgrade pip

Install uv

macOSLinuxCareful

uv is a very fast Python package and project manager.

curl -LsSf https://astral.sh/uv/install.sh | sh

Pipes a script from the internet into your shell. This is the official installer; read it first if unsure.

Start a project with uv

macOSWindowsLinux

Creates pyproject.toml, a starter main.py and a .gitignore.

uv init && cd

Add a package with uv

macOSWindowsLinux

Installs it into the project environment and records it in pyproject.toml.

uv add

Run a script with uv

macOSWindowsLinux

Runs inside the project environment, syncing dependencies first.

uv run

Pretty-print JSON

macOSWindowsLinux

Formats a JSON file with indentation. Also works on piped input.

python3 -m json.tool

Which Python am I using?

macOSLinux

Path and version of the active interpreter.

which python3 && python3 --version

Every command copies as plain, clean text: no curly quotes, no long dashes, no invisible characters.

Related guides