Python Dev Environment Cheat Sheet

This page condenses how to set up a Python development environment into one reference: the terminal, installing uv and Python, working in uv projects, connecting your editor, venv and pip, REPLs and notebooks, Ruff, Git, and testing. You can also download the information as a printable cheat sheet:

Free Bonus: Python Dev Environment Cheat Sheet

Get a Python Dev Environment Cheat Sheet (PDF) with the terminal, uv, venv, editor, Ruff, and Git commands you need to set up and run your Python projects:

Python Dev Environment Cheat Sheet

Practice with hands-on coding exercises, quizzes, and a personal AI mentor. Not sure what to learn next? Get your free personal learning plan.

Setting up Python for the first time?

Your Starter Setup

  • Joining a project? Follow its setup instructions and tools.
  • Add more tools only when you hit a problem they solve.
Part Start with
Code editor VS Code + Python extension
Terminal Your system’s shell
Python and packages uv
Project One folder per project

Not sure what you actually need?

Terminal Basics

  • The terminal is the app, the shell runs your commands.
  • Bash commands don’t always work as-is in PowerShell.
Language: Shell Filename: Navigate on macOS and Linux
$ pwd              # Show current folder
$ ls               # List its contents
$ mkdir projects   # Create a folder
$ cd projects      # Move into it
$ cd ..            # Go up one level
Language: Windows PowerShell Filename: Navigate on Windows
PS> Get-Location     # Show current folder
PS> Get-ChildItem    # List its contents
PS> mkdir projects   # Create a folder
PS> cd projects      # Move into it
PS> cd ..            # Go up one level

Want more practice in the terminal?

Install uv and Python

  • uv’s installer works even before you have Python.
  • uv-managed Pythons leave your system Python alone.
Language: Shell Filename: Install on macOS and Linux
$ curl -LsSf \
    https://astral.sh/uv/install.sh | sh
Language: Windows PowerShell Filename: Install on Windows
PS> irm https://astral.sh/uv/install.ps1 |
>>   iex
Language: Shell Filename: Manage Python Versions
$ uv python install 3.15   # Get a version
$ uv python list           # See versions
$ uv init --python 3.15 app

Worried about multiple Pythons?

Work in a uv Project

  • uv run uses the project’s .venv, no activation needed.
  • Use uv add, not uv pip install, to record dependencies.
Language: Shell Filename: Create a Project and Add Packages
$ uv init hello      # New project folder
$ cd hello
$ uv add requests    # Add a dependency
$ uv run app.py      # Run in the project env
Language: Shell Filename: Everyday Commands
$ uv add --dev pytest   # Dev-only dependency
$ uv remove requests    # Drop a dependency
$ uv sync               # Rebuild .venv
$ uv tree               # Show dependencies
File Commit it?
pyproject.toml: project and deps Yes
.python-version: Python to use Yes
uv.lock: exact resolved versions Yes
.venv/: the environment No

Think you’ve got uv projects down?

Connect Your Editor

  • In VS Code, run Python: Select Interpreter and pick the project’s .venv.
  • ModuleNotFoundError after an install? Your editor runs a different Python.
  • Prefer an IDE? Try PyCharm. Want something minimal? Try Thonny.
Language: Python Filename: Check Which Python Runs Your Code
>>> import sys
>>> sys.executable
'/home/user/hello/.venv/bin/python'

Editor can’t find your packages?

Use venv and pip

  • python -m pip installs into the Python you just ran.
  • Still common in tutorials and existing projects.
Language: Shell Filename: Create and Activate on macOS and Linux
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ deactivate
Language: Windows PowerShell Filename: Create and Activate on Windows
PS> python -m venv .venv
PS> .venv\Scripts\activate
(.venv) PS> deactivate
Language: Shell Filename: Install Packages
$ python -m pip install requests
$ python -m pip freeze > requirements.txt
$ python -m pip install -r requirements.txt

Still fuzzy on virtual environments?

REPL, Notebooks, and Tools

  • Command-line apps get their own env with uv tool or uvx.
  • A notebook’s kernel needs the env that has your packages.
Language: Shell Filename: Explore Interactively
$ uv run python    # REPL with project deps
$ uv run --with jupyter jupyter lab
Language: Shell Filename: Install and Run Command-Line Tools
$ uv tool install ruff  # Install for good
$ uvx ruff --version    # Run, no install
$ uv tool list          # Installed tools

Project dependency or standalone tool?

Get Feedback: Ruff and Git

  • Ruff lints and formats. Let your editor run it on save.
  • Git tracks every change, locally, before you share anything.
Language: Shell Filename: Lint and Format With Ruff
$ uv add --dev ruff
$ uv run ruff check          # Find problems
$ uv run ruff check --watch  # On every save
$ uv run ruff format         # Fix layout
Language: Shell Filename: Record Changes With Git
$ git init            # uv init does this
$ git add .
$ git commit -m "Add greeting"
$ git log --oneline   # See history

Ready to test yourself?

Test Your Code

  • Keep test runners in dev dependencies so they can import your project.
Language: Python Filename: test_greet.py
def greet(name):
    return f"Hello, {name}!"

def test_greet():
    assert greet("Ada") == "Hello, Ada!"
Language: Shell Filename: Run the Tests
$ uv add --dev pytest
$ uv run pytest      # Run all tests
$ uv run pytest -x   # Stop at first failure

Want to go deeper on testing?

Fix Common Setup Problems

Problem Try this
ModuleNotFoundError Point your editor at the project’s .venv
uv: command not found Open a new terminal after installing uv
Windows blocks activate Allow local scripts with Set-ExecutionPolicy
Notebook can’t import a package Pick the kernel from the env with your packages

Stuck on a different setup problem?

Ready to go beyond the cheat sheet?

You can download this information as a printable cheat sheet:

Free Bonus: Python Dev Environment Cheat Sheet

Get a Python Dev Environment Cheat Sheet (PDF) with the terminal, uv, venv, editor, Ruff, and Git commands you need to set up and run your Python projects:

Python Dev Environment Cheat Sheet