Skip to content
Latchkey

pip install: Usage, Options & Common CI Errors

The command you run most in any Python pipeline, with the CI gotchas.

pip install fetches packages from an index (PyPI by default) and installs them into the active environment. It is the workhorse of nearly every Python CI job.

What it does

Resolves and installs one or more packages, plus their dependencies, into the current Python environment. You can pin exact versions, ranges, extras, or install from VCS, local paths, and URLs.

Common usage

Terminal
pip install requests
pip install "requests==2.32.3"
pip install "django>=4.2,<5.0"
pip install "fastapi[all]"
pip install --upgrade pip
pip install "git+https://github.com/psf/requests.git@main"

Common CI error: externally-managed-environment

On Debian/Ubuntu runners a bare "pip install" into the system interpreter fails with "error: externally-managed-environment" (PEP 668). Fix it by installing into a virtual environment instead.

Terminal
# Failure on a system Python:
# error: externally-managed-environment

# Fix: create and use a venv
python -m venv .venv
. .venv/bin/activate
pip install requests

Options

OptionDoes
-U, --upgradeUpgrade to the newest version
-t, --target DIRInstall into a specific directory
--userInstall to the user site-packages
--preAllow pre-release versions
--no-depsSkip installing dependencies
-i, --index-url URLUse an alternate package index

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →