Install python on Mac through pyenv

Selina Li
1 min readMay 29, 2022

--

There are multiple ways to do this. This article covers the way to do this through pyenv and provides easy access to most frequently used command lines.

Step 1: Install or update homebrew

If you just get your brand new Macbook and you have not installed homebrew, install it through Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

If you have already installed, update it by:

brew update

Step 2: Install pyenv

brew install pyenv

Step 3: Set up shell environment for pyenv

Check Set up your shell environment for Pyenv

Step 4: Use pyenv to install and select your desirable python version

  • To check current selected Python versions
pyenv versions

Because you have not selected any Python version, you will most likely see your python version as system

If you want to know which version your system uses, check by:

python -V
  • To check what versions are available
pyenv install --list | grep " 3\.[678]"
  • To install selected python version

For example, to install python version 3.8.6:

pyenv install 3.8.6
  • To apply a specific python version to globally
pyenv global 3.8.6

Then you can check your global Python version by:

python -V
  • To check where pyenv installed python
pyenv which python

--

--