python -m pip install requestsAlways this form. A barepipmay belong to a different interpreter than thepythonyou're about to run.★python -m pip --versionPrints pip's version and the Python it will install into. Read the second half.★python -m pip install -U pipUpgrade pip itself.pip --python /path/to/python listDrive a different interpreter's environment from this one.pip config listEvery config file and env var currently in effect. Start debugging here.
python -m venv .venvpip installs into whatever Python it's attached to. A venv is what makes that safe.★source .venv/bin/activateWindows:.venv\Scripts\activate. Thendeactivateto leave.★.venv/bin/python -m pip install -r requirements.txtNo activation needed — call the venv's interpreter directly. Best for scripts & CI.pipx install ruffFor CLI tools, not libraries. Each gets its own hidden venv.pip install --break-system-packages xThe PEP 668 override. Can breakapt/Homebrew. Disposable containers only.last resort
pip install requestsNewest compatible release, plus its dependencies.★pip install "requests==2.32.3"Pin exactly. See card 05 for the full operator set.★pip install -r requirements.txtInstall a whole file of specs.★pip install -U requests--upgrade. Note: it does not upgrade dependencies unless they're too old.pip install -e .Editable. Your source dir is linked in — edits take effect with no reinstall.★pip install .Build the current project and copy it in. A snapshot, not a link.pip install --dry-run --report r.json xResolve, change nothing, dump the plan as JSON.pip install --no-deps xJust this package. Pairs with a fully-pinned lockfile.
pip install -i https://my.co/simple x--index-urlreplaces PyPI.pip install --extra-index-url URL xAdds an index. Careful: a public PyPI name can shadow your private one.pip install "proj @ git+https://github.com/o/r@v1.2"Straight from a tag, branch or commit.pip install ./dist/pkg-1.0-py3-none-any.whlA local wheel. No index touched.pip install --no-index -f ./wheels -r req.txtFully offline, from a wheelhouse directory.pip index versions requestsWhich versions exist.pip searchis dead — PyPI removed that API.
requests==2.32.3Exactly this version. Whatpip freezeemits.★requests==2.32.*Any release starting2.32.requests~=2.32.3Compatible release — means>=2.32.3, ==2.32.*. See the diagram below.★"requests>=2.28,<3"A range. Comma is AND. Quote it — the shell eats<and>.★"requests!=2.30.0"Exclude one bad release.pip install --pre xPre-releases are ignored by default; this opts in.
pip install "fastapi[standard]"Extras — optional dependency bundles the package declares.★pip install "pkg[dev,test]"Several at once.pip install -e ".[dev]"Your own project, editable, with its dev extra. The standard dev-setup line.★pkg; python_version < "3.12"Environment marker — install only where the condition holds.pkg; sys_platform == "win32"Also:platform_machine,implementation_name,os_name.pip install --group devPEP 735 dependency-group frompyproject.toml.
pip listEverything installed, with versions.★pip list --outdatedWhat has a newer release available.★pip list --not-requiredTop-level only — nothing else depends on these. The real "what did I ask for".★pip show requestsVersion, location,Requires:andRequired-by:.pip show -f requestsEvery file the package installed.pip checkAre the installed deps mutually consistent? Run after any manual surgery.★pip inspectThe whole environment as machine-readable JSON.
pip freeze > requirements.txtDumps everything installed, pinned. Convenient, blunt — it can't tell your intent from a transitive dep.★-r base.txtRequirements files can include each other.dev.txtstarts with-r base.txt.-e .Editable lines are legal inside a requirements file too.--hash=sha256:abc…Add one hash and pip switches the whole file into hash-checking mode.pip install -c constraints.txt -r req.txtConstraints only cap versions — they never cause an install. Use them to pin transitive deps.★pip hash dist/pkg.whlCompute the hash to paste into the file.
pip lock -e .Emitpylock.toml— a real, resolved, hashed lockfile. Experimental.★pip lock -r req.txt -o pylock.tomlLock from an existing requirements file.pip install -r pylock.tomlInstall from the lock. Valid for this Python and platform only.pip install --uploaded-prior-to 2026-01-01 pkgNew in pip 26.0: ignore any distribution uploaded after that datetime — reproduce an older working resolution (pip's answer to uv's--exclude-newer).pip install --require-hashes -r req.txtRefuse anything unhashed. The deployment safety net.★pip download -r req.txt -d ./wheelsFetch without installing — build an offline bundle.pip wheel -r req.txt -w ./wheelsBuild every dependency to a wheel once, then install from the dir anywhere.
pip uninstall requestsRemoves the package — not its dependencies. They linger as orphans.leaves orphanspip uninstall -y -r requirements.txtBulk removal, no prompts.destructivepip cache infoSize and location of both caches.pip cache list numpyWhich wheels are cached for a package.pip cache remove numpySurgical. The fix when a bad cached wheel keeps coming back.pip cache purgeNuke both caches. Safe — just costs you re-downloads.pip install --no-cache-dir xOnly in container builds that cache a layer above. Otherwise it just makes pip slow.
pip install --only-binary=:all: xNever compile. Fails loudly instead of silently spending 10 minutes on a C build.★pip install --no-binary=:all: xForce a build from sdist — e.g. to pick up local CPU optimizations.pip install --prefer-binary xTake an older wheel over a newer sdist.pip install --no-build-isolation xBuild against the current env instead of a clean one. Build deps must already be present.pip debugShows the compatible wheel tags for this interpreter — the answer to "why is there no wheel for me".
pip install tea "cup>=3.13"Add a lower bound on whatever it's backtracking on. Shrinks the search space dramatically.★pip install -c constraints.txt teaSame idea, for transitive deps you can't name on the CLI.pip install -U pkg-a pkg-bFixesResolutionTooDeep: ignore what's installed and resolve fresh.# loosen the pinsResolutionImpossibleusually means you over-pinned. Drop==to>=and let pip find the overlap.★pip install --force-reinstall xReinstall even if satisfied. A blunt fix for a corrupted install.
pip config set global.index-url URLPersist a private index instead of retyping-i.pip config set global.require-virtualenv trueRefuse to install outside a venv. The best guardrail pip offers.★export PIP_REQUIRE_VIRTUALENV=1Every flag has aPIP_*env var. Underscores or dashes both work.export PIP_CONSTRAINT=constraints.txtApplies constraints to every pip run — including builds. Handy in CI.pip config debugWhich file won, and why.
(nothing)The active environment. If no venv is active, that's your system Python — the source of most pip disasters.★--user~/.local/…. Blocked on PEP 668 systems. Prefer a venv.--target ./libsDump packages into a plain directory — AWS Lambda bundles, vendoring.--prefix /opt/appInstall into a custom prefix tree.--python .venv/bin/pythonExplicitly name the interpreter to act on.