Linux Python Dev Env

Modern Python development setup on Linux.
Dev Env
Published

August 11, 2024

Modified

June 1, 2025

Linux Python dev env

Linux Python dev env

Installing Python development tools on Linux can easily pollute your system environment if done carelessly. This guide covers how to set up an isolated, reproducible Python development workstation on Linux using brew, pipx, and modern project tooling.

Installing Python Runtimes

First, install the target Python interpreters via Homebrew:

brew install python@3.12 python@3.13

Global CLI Tools with Pipx

Development CLI utilities (such as linters, formatters, and task runners) should be accessible globally across all terminal sessions, but should never be installed into your default system or global Python site-packages.

The solution is pipx, which installs each CLI tool into its own isolated virtual environment while exposing its binary on your $PATH:

brew install pipx
pipx ensurepath
pipx install argcomplete --force

Add pipx shell completions to your ~/.zshrc:

autoload -U compinit && compinit
eval "$(register-python-argcomplete pipx)"

Pipx argcomplete setup in terminal

Pipx argcomplete setup in terminal

Installing Core Developer Utilities

Now install your everyday terminal development tools:

pipx install --force ruff hapless poethepoet poetry pre-commit uv pytest basedpyright

Installing core utilities with pipx

Installing core utilities with pipx

How Pipx Manages Isolation

Inspect the generated launcher for any installed tool:

nano $(which poetry)

Inspecting pipx launcher shebang in nano

Inspecting pipx launcher shebang in nano

Notice the shebang (#!) line points to an interpreter inside ~/.local/share/pipx/venvs/poetry/bin/python. This launcher script sets up the execution environment before delegating to the underlying package.

Each tool installed with pipx lives in a dedicated, hermetic virtual environment:

ls ~/.local/share/pipx/venvs/ -la

Directory listing of pipx virtual environments

Directory listing of pipx virtual environments

Initializing a Project Repository

Clone or navigate into your project repository, install the dependencies, and configure pre-commit hooks:

# Install project dependencies
poetry install

# Install and configure git pre-commit hooks
pre-commit install --install-hooks --overwrite --allow-missing-config
pre-commit autoupdate

# Run checks across all files to verify environment integrity
pre-commit run --all-files

With this architecture, your global tools stay isolated, dependencies never conflict, and each repository manages its own hermetic virtual environment.

Back to top