Python venv Project Setup Cheat Sheet

Project-level setup patterns for Python virtual environments, pyproject.toml, editable installs, dev tools, and team onboarding.

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

Project bootstrap

Create a local environment and prepare a project for work.

Create project and venv

Create a project folder and initialize a virtual environment.

bashANYbootstrapprojectvenv
bash
mkdir myapp && cd myapp && python -m venv .venv

A common project-start sequence.

Ignore the local venv in Git

Add the environment directory to .gitignore.

gitignoreANYgitignorevenvproject
gitignore
.venv/
venv/
__pycache__/
*.pyc

You normally commit dependency files, not the environment directory itself.

Install common local tooling

Install formatter, linter, and test tooling in the venv.

bashANYtoolingblackruffpytest
bash
python -m pip install black ruff pytest

A typical local developer-tool bootstrap step.

pyproject.toml patterns

Use modern Python project metadata and local installs with venv.

Minimal pyproject.toml example

Basic modern packaging metadata for a local project.

tomlANYpyprojecttomlpackaging
toml
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "myapp"
version = "0.1.0"
dependencies = [
  "requests>=2.31",
]

A starting point for modern packaging metadata and editable installs.

Install project editable from pyproject

Install the current project into the venv in editable mode.

bashANYeditablepyprojectdevelopment
bash
python -m pip install -e .

Useful for app and library development using modern metadata.

Install editable with dev extras

Install project plus optional development dependencies.

bashANYeditableextrasdev
bash
python -m pip install -e ".[dev,test]"

Useful when your project defines optional dependency groups for contributors.

Team onboarding and automation

Make local setup fast and consistent for teammates.

Typical README quick-start block

Copy-paste setup commands for local onboarding.

markdownANYreadmeonboardingsetup
markdown
```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip setuptools wheel
python -m pip install -r requirements.txt
```

A good onboarding pattern for repository documentation.

Makefile setup target

Automate local environment setup for contributors.

makefileANYmakefilesetupautomation
makefile
setup:
  python -m venv .venv
  . .venv/bin/activate && python -m pip install -U pip setuptools wheel
  . .venv/bin/activate && python -m pip install -r requirements.txt

A small quality-of-life improvement that helps teams onboard quickly.

Auto-activate with direnv + layout python

Example .envrc for shells that use direnv.

bashANYdirenvautomationshell
bash
layout python python3

An optional workflow for automatic environment handling in supported shells.

Recommended next

No recommendations yet.