Skip to main content

Pyenv

Pyenv is a Python version manager that makes it easy to install and switch between multiple Python versions on the same machine.

Features

  • 📦 Manage multiple Python versions
  • 🔄 Switch versions quickly
  • 🎯 Pin a specific version for each project
  • 🌐 Support virtual environments
  • 🪟 Cross-platform support for Windows, Linux, and macOS

Installation

Windows

Use pyenv-win:
Add environment variables:

Linux/macOS

Configure your shell by adding the following to ~/.bashrc or ~/.zshrc:

Basic usage

Show installable versions

Install Python versions

Show installed versions

Switch Python versions

Uninstall a version

Advanced usage

Set a version for a project

Virtual environments

Use it together with pyenv-virtualenv:

Show where the current version comes from

Refresh shims

Configuration files

Global configuration

Project configuration

Shell configuration

FAQ

Installation failed

Missing Linux dependencies:

Version switching does not take effect

Windows path issues

Make sure the environment variables are configured correctly, then restart the terminal.

Comparison with other tools

Best practices

  1. Set a local version for every project to avoid global version conflicts.
  2. Use virtual environments together with pyenv-virtualenv.
  3. Commit .python-version when the team should use the same version.
  4. Update pyenv regularly to get support for new versions.
  5. Record dependencies with requirements.txt or Pipfile.

Quick reference

References

Last modified on April 17, 2026