Member-only story

How to Manage Multiple Python Versions with Pyenv

Simone Mayers
3 min readNov 11, 2024

--

Why Use Pyenv?

With pyenv, you gain:

  • Flexible version control: Install and switch between multiple Python versions on a global or per-project basis.
  • Easy version updates: Install new Python versions without altering your system’s default Python.
  • Integration with virtualenv: You can use pyenv with virtualenv (via pyenv-virtualenv) to manage both Python versions and isolated environments.

Setting Up Pyenv

1. Install Pyenv

Installation varies by operating system, but here’s a quick rundown for macOS and Linux. (Windows users can use a tool like pyenv-win for similar functionality.)

On macOS/Linux:

You can install pyenv using Homebrew (macOS) or by cloning it directly from GitHub.

With Homebrew:

brew install pyenv

Using GitHub:

curl https://pyenv.run | bash

After installation add the following lines to your shell configuration file (.bashrc , .zshrc , etc.) to enable pyenv :

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init - path)"
eval "$(pyenv init -)"

Reload your shell:

source ~/.bashrc # or `source ~/.zshrc`

2. Install Multiple Python…

--

--

Simone Mayers
Simone Mayers

No responses yet