Python venv + pip Cheat Sheet

Package installation, requirements, editable installs, wheel workflows, and dependency troubleshooting inside Python virtual environments.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Requirements and lock-style workflows

Install and snapshot dependencies consistently.

Install a requirements file

Install project dependencies from requirements.txt.

bashANYrequirementsinstallpip
bash
python -m pip install -r requirements.txt

Standard setup command for many Python apps.

Install development requirements

Install a second requirements file for dev-only tools.

bashANYrequirementsdevelopmentpip
bash
python -m pip install -r requirements-dev.txt

Common when separating runtime and developer tooling.

Write a requirements snapshot

Freeze the current environment to a file.

bashANYfreezerequirementssnapshot
bash
python -m pip freeze > requirements.txt

Captures exact package versions in pip format.

Compare installed packages to requirements

Diff the current environment snapshot against a file.

bashANYfreezediffrequirements
bash
diff -u requirements.txt <(python -m pip freeze)

Useful on bash/zsh to see dependency drift quickly.

Install without dependencies

Install a package while skipping dependency resolution.

bashANYinstallno-depspip
bash
python -m pip install --no-deps mypackage

Useful in controlled builds or when debugging dependency issues.

Install from hash-checked requirements

Require pinned hashes during install.

bashANYrequirementshashessecurity
bash
python -m pip install --require-hashes -r requirements.txt

Stricter installs for reproducibility and integrity checks.

Editable and local installs

Develop libraries and applications locally within a venv.

Editable install of current project

Install the current project in editable mode.

bashANYeditablelocalpip
bash
python -m pip install -e .

Common for local development so changes are reflected without reinstalling.

Editable install with extras

Install development extras from pyproject or setup metadata.

bashANYeditableextrasdevelopment
bash
python -m pip install -e ".[dev]"

Convenient when your project defines optional development dependencies.

Install from a wheel file

Install a local built wheel into the venv.

bashANYwheelinstallartifact
bash
python -m pip install dist/my_package-0.1.0-py3-none-any.whl

Useful for testing built artifacts in a clean environment.

Install from a source tarball

Install a local source distribution file.

bashANYsdistinstallartifact
bash
python -m pip install dist/my_package-0.1.0.tar.gz

Useful when validating source distribution packaging.

Wheelhouse and offline patterns

Prepare or reuse package artifacts without live internet installs.

Build wheels for requirements

Create wheel artifacts for dependencies.

bashANYwheelrequirementsoffline
bash
python -m pip wheel -r requirements.txt -w ./wheelhouse

Builds or downloads wheel files into a local directory for faster later installs.

Install only from a local wheelhouse

Install using local artifacts and no package index.

bashANYwheelhouseofflineinstall
bash
python -m pip install --no-index --find-links=./wheelhouse -r requirements.txt

Useful for offline environments or repeatable deployments.

Show pip cache directory

Print where pip caches downloaded artifacts.

bashANYcachepipinspect
bash
python -m pip cache dir

Good starting point when troubleshooting repeated downloads or cache bloat.

Purge pip cache

Clear the local pip cache.

bashANYcachepurgepip
bash
python -m pip cache purge

Useful when stale cache state may be causing confusion.

Dependency debugging

Figure out why an environment behaves differently than expected.

Show package install location

Display metadata and install location for a package.

bashANYpipshowlocation
bash
python -m pip show urllib3

Use this to confirm whether a package is installed in the active venv versus a base interpreter.

List outdated packages

Show packages with newer available versions.

bashANYpipoutdatedupgrade
bash
python -m pip list --outdated

Useful when planning upgrades or security remediation.

Show pip debug info

Print pip environment diagnostics.

bashANYpipdebugdiagnostics
bash
python -m pip debug

Helpful when debugging platform tags, config, or install behavior.

Print Python import path

Show sys.path for the active environment.

bashANYsys.pathimportsdebugging
bash
python -c "import sys; print('
'.join(sys.path))"

Useful when imports succeed or fail unexpectedly due to path order.

Print imported package version

Check the version of an imported module at runtime.

bashANYimportsversiondebugging
bash
python -c "import requests; print(requests.__version__)"

Confirms which version is actually importable in the active venv.

Recommended next

No recommendations yet.