A Comprehensive Overview of Python Version, Environment, and Package Management Tools
This article provides a detailed guide to Python version management, package management, virtual environment handling, package building, and publishing tools, comparing utilities like pyenv, venv, virtualenv, pip, pipenv, conda, Poetry, pdm, Hatch, and Rye, and explaining their motivations, commands, and feature support.
Background
When I started using Python and creating my first package, I was confused. Managing packages and environments turned out to be more difficult than expected, and many tools exist without a clear overview. This article aims to give a structured evaluation of those tools.
Tool Classification
The tools are divided into five important categories for environment and package management:
Python version management
Package management
Environment management (mainly virtual environments)
Package building
Package publishing
Many tools overlap categories; some are single‑purpose, others are multi‑purpose.
Python Version Management
A tool for Python version management should allow easy installation of Python versions and switching between them.
Motivation
Different projects may require different Python versions, or you may want to test a library against multiple versions. You also might want to try the latest features or pre‑release versions.
Tools
The Venn diagram shows four main tools: pyenv , conda , rye , and PyFlow . Below is a brief look at pyenv :
<code># Install a specific Python version
pyenv install 3.10.4
# Switch between versions (global, local, shell)
pyenv shell <version>
pyenv local <version>
pyenv global <version>
</code>Environment Management (Virtual Environments)
Definition
Environment management tools let you create and manage (virtual) environments.
Motivation
Projects often need different versions of the same dependency, leading to conflicts. Virtual environments isolate dependencies per project.
Tools
Common tools include venv , virtualenv , pipenv , conda , pdm , poetry , hatch , rye , and PyFlow . The two built‑in single‑purpose tools are:
venv
Built‑in Python module for creating virtual environments. Important commands:
<code># Create a new environment
python3 -m venv <env_name>
# Activate the environment
. <env_name>/bin/activate
# Deactivate
deactivate
</code>virtualenv
Improved version of venv with more features and speed.
<code># Create a new environment
virtualenv <env_name>
# Activate
. <env_name>/bin/activate
# Deactivate
deactivate
</code>Package Management
Definition
Package managers download and install libraries and their dependencies.
Motivation
Packages provide a hierarchical module structure and a convenient import syntax, and they enable sharing code with other developers.
Tools
Popular tools include pip , pipx , pipenv , conda , pdm , poetry , rye , and PyFlow . The most well‑known is pip :
<code># Install a package
pip install <package_name>
</code>Multi‑Purpose Tools
pipenv
Combines pip and virtualenv , handling both dependency and environment management.
<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 Python and non‑Python packages. It also supports building and publishing packages, though its workflow differs from the pure‑Python tools.
Flit
Focused on building and publishing pure‑Python packages. It does not manage versions, dependencies, or environments.
<code># Initialize a new pyproject.toml
flit init
# Build and publish
flit publish
</code>Poetry
Handles package management, environment management, building, and publishing (but not Python version management).
<code># Create a new project structure
poetry new <project_name>
# Interactive pyproject.toml creation
poetry init
# Install dependencies
poetry install
# Add a dependency
poetry add <package_name>
# Show dependency tree
poetry show --tree
# Build package
poetry build
# Publish to PyPI
poetry publish
</code>pdm
Inspired by Poetry and PyFlow, supports package management, environment management, building, and publishing. It implements PEP 582 (local packages).
<code># Interactive pyproject.toml creation
pdm init
# Install packages
pdm install
# Add a dependency
pdm add <package_name>
# List dependencies as a graph
pdm list --graph
# Run a script (no dedicated shell command)
pdm run python <script_name.py>
# Build and publish
pdm build
pdm publish
</code>Hatch
Manages environments declaratively via pyproject.toml , supports building and publishing, and allows plugins.
<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 (virtual environment)
hatch shell
# Run a script inside the environment
hatch run python <script_name.py>
# Build and publish
hatch build
hatch publish
</code>Rye
Developed by the creator of Flask, written in Rust, and supports all five categories (version, package, environment, build, publish).
<code># Initialize a new project
rye init <project_name>
# Pin a Python version
rye pin 3.10
# Add a dependency (not installed yet)
rye add <package_name>
# Sync virtual environment and lock file (installs dependencies)
rye sync
# Open a shell
rye shell
# Run a script inside the environment
rye run python <script_name.py>
# Build and publish
rye build
rye publish
</code>Summary Table
Flit
Poetry
pdm
Hatch
Rye
Manages dependencies
❌
✅
✅
❌
✅
Resolves/locks dependencies
❌
✅
✅
❌
✅
Clean build/publish flow
✅
✅
✅
✅
✅
Supports plugins
❌
✅
✅
✅
❌
Supports PEP 660
✅
✅
✅
✅
✅
Supports PEP 621
✅
❌
✅
✅
✅
For further reading and resources, see the linked articles at the end of the original post.
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.