Use pip with Python 3 explicitly
Install a package with a specific interpreter family.
python3 -m pip install requestsSafer than calling `pip` directly on systems with multiple Python installs.
Use pip correctly across Python versions, venvs, pyenv-style setups, CI, and system interpreters.
Install a package with a specific interpreter family.
python3 -m pip install requestsSafer than calling `pip` directly on systems with multiple Python installs.
Install into Python 3.11 specifically.
python3.11 -m pip install requestsGreat when several minor versions are installed side-by-side.
python -c "import sys; print(sys.executable)"Useful before installing packages so you know where they will land.
Typical Unix-like local development flow.
python -m venv .venv && source .venv/bin/activate && python -m pip install --upgrade pipCreates an isolated environment, activates it, and upgrades pip inside it.
Install project dependencies after activation.
python -m pip install -r requirements.txtOnce the venv is active, `python -m pip` targets that environment.
Install packages into the user site directory.
python -m pip install --user httpieHelpful when you cannot write to system site-packages. Avoid inside a venv.
Override system package management protections when necessary.
python -m pip install --break-system-packages requestsUse cautiously. On many Linux distributions, using a venv is safer.
Bootstrap common packaging tools in CI.
python -m pip install --upgrade pip setuptools wheelA common setup step before building or installing packages in automation.
python -m pip install --no-input -r requirements.txtUseful in CI systems or scripts where prompts would hang execution.
Skip pip’s self-update version check.
PIP_DISABLE_PIP_VERSION_CHECK=1 python -m pip install -r requirements.txtCan reduce noise and shave a small amount of time in CI.