A Comprehensive Overview of Python Version, Environment, and Package Management Tools
This article provides a detailed classification and comparison of essential Python tooling—including version managers, virtual environment managers, package managers, and build/publish utilities—explaining their motivations, core commands, and feature support such as dependency locking, PEP 660, and PEP 621.
Tool Classification
The article divides Python tooling into five important categories: Python version management, package management, environment management (mainly virtual environments), package building, and package publishing.
Python Version Management
Tools that let you install multiple Python versions and switch between them are essential when working on projects that require different runtimes. The Venn diagram shows four tools: pyenv , conda , rye , and PyFlow . The article first examines pyenv and then discusses multi‑purpose tools.
<code># Install a specific Python version
pyenv install 3.10.4
# Switch between versions for the current shell
pyenv shell <version>
# Use a version automatically in a directory
pyenv local <version>
# Set a global version for the user
pyenv global <version>
</code>Environment Management
Virtual environments isolate project dependencies to avoid conflicts. Tools include the built‑in venv , virtualenv , and multi‑purpose managers such as pipenv , conda , pdm , poetry , hatch , and rye .
venv
<code># Create a new environment
python3 -m venv <env_name>
# Activate the environment
. <env_name>/bin/activate
# Deactivate the environment
deactivate
</code>virtualenv
<code># Create a new environment
virtualenv <env_name>
# Activate the environment
. <env_name>/bin/activate
# Deactivate the environment
deactivate
</code>Package Management
The central file for modern Python packaging is pyproject.toml (PEP 518). The article shows a snippet from pandas' configuration and explains the role of lock files (e.g., poetry.lock ) for reproducible builds.
<code>[build-system]
requires = ["meson-python==0.13.1", "meson==1.2.1", "wheel", "Cython==3.0.5", "numpy>1.22.4,<=2.0.0.dev0", "versioneer[toml]"]
build-backend = "mesonpy"
[project]
name = 'pandas'
dynamic = ['version']
description = 'Powerful data structures for data analysis, time series, and statistics'
readme = 'README.md'
authors = [{name = 'The Pandas Development Team', email = '[email protected]'}]
license = {file = 'LICENSE'}
requires-python = '>=3.9'
dependencies = ["numpy>=1.22.4; python_version<'3.11'", "numpy>=1.23.2; python_version=='3.11'", "numpy>=1.26.0; python_version>='3.12'", "python-dateutil>=2.8.2", "pytz>=2020.1", "tzdata>=2022.7"]
</code>Lock files record exact versions, e.g., pandas==2.0.3 , ensuring reproducibility across platforms.
Multi‑Purpose Tools
pipenv
Combines pip and virtualenv . It introduces Pipfile and Pipfile.lock for deterministic builds.
<code># Install a package
pipenv install <package_name>
# Run a script inside the virtual environment
pipenv run <script_name.py>
# Activate the virtual environment
pipenv shell
</code>Conda
A general‑purpose package manager that works for languages beyond Python. It can also build and publish packages, though its workflow differs from the Python‑specific tools.
Flit
Focused on publishing pure‑Python packages. It supports PEP 660 and PEP 621 but does not manage dependencies or environments.
<code># Initialize a new pyproject.toml
flit init
# Build and publish
flit publish
</code>Poetry
Handles dependency management, virtual environments, building, and publishing (except Python version management). It supports PEP 660 but not PEP 621.
<code># Create a new project
poetry new <project_name>
# Interactive init
poetry init
# Install dependencies
poetry install
# Add a dependency
poetry add <package_name>
# Show dependency tree
poetry show --tree
# Build and publish
poetry build
poetry publish
</code>pdm
Inspired by Poetry and PyFlow, it supports all tasks except Python version management and implements PEP 582 (local packages) though the PEP was rejected.
<code># Interactive init
pdm init
# Install packages
pdm install
# Add a dependency
pdm add <package_name>
# List dependencies as a graph
pdm list --graph
# Build and publish
pdm build
pdm publish
</code>Hatch
Manages environments and builds/publishes packages. It currently lacks dependency locking but plans to add it.
<code># Create a new project
hatch new <project_name>
# Initialize an existing project
hatch new --init
# Show dependencies in a table
hatch dep show table
# Open a shell
hatch shell
# Run a script
hatch run python <script_name.py>
# Build and publish
hatch build
hatch publish
</code>Rye
Developed by the creator of Flask, Rye is written in Rust and covers all five categories. It currently has no plugin system.
<code># Initialize a project
rye init <project_name>
# Pin a Python version
rye pin 3.10
# Add a dependency (no install yet)
rye add <package_name>
# Sync virtual environment and install dependencies
rye sync
# Open a shell
rye shell
# Run a script
rye run python <script_name.py>
# Build and publish
rye build
rye publish
</code>Feature Comparison
Feature
Flit
Poetry
pdm
Hatch
rye
Manages dependencies
❌
✅
✅
❌
✅
Resolves/locks dependencies
❌
✅
✅
❌
✅
Clean build/publish flow
✅
✅
✅
✅
✅
Supports plugins
❌
✅
✅
✅
❌
PEP 660 support
✅
✅
✅
✅
✅
PEP 621 support
✅
❌
✅
✅
✅
The article concludes with a summary table that highlights which tools satisfy each evaluation dimension.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.