Fix Python Version on macOS Using Pyenv

Thu Jan 08 2026

Fix Python Version on macOS Using Pyenv

๐Ÿ Fix Python Version

If you're working with Python regularly โ€” especially across multiple projects โ€” managing different versions can get messy. Thatโ€™s where pyenv shines. It allows you to install and maintain multiple Python versions without conflicts.

In this guide, youโ€™ll learn how to install pyenv, configure it to work with Zsh, and set your preferred global Python version.


โœ… Why Use pyenv?

  • Keeps multiple Python versions isolated
  • Avoids conflicts between system Python and project Python
  • Works perfectly with Zsh and virtual environments
  • Ideal for developers working across varied projects

๐Ÿ”ง Step 1 โ€” Install pyenv

First, make sure Homebrew is up to date and then install pyenv.

brew update
brew install pyenv

๐Ÿ›  Step 2 โ€” Configure Your Zsh Shell (.zshrc)

Open your Zsh configuration file:

nano ~/.zshrc

Add these lines at the end of the file:

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Save and exit the editor:

  • Ctrl + O โ†’ Enter
  • Ctrl + X

Reload the shell to apply changes:

source ~/.zshrc

โฌ Step 3 โ€” Install the Latest Python Version

List available Python versions:

pyenv install --list

Install a stable version (example: Python 3.14.2):

pyenv install 3.14.2

๐ŸŒ Step 4 โ€” Set the Global Python Version

Set your system-wide Python to the version you installed:

pyenv global 3.14.2

Verify the update:

python --version
# OR
python3 --version

Expected output:

Python 3.14.2

๐ŸŽ‰ Youโ€™re Ready to Code!

You now have: โœ” pyenv installed โœ” Zsh configured โœ” A specific Python version set as global โœ” Ability to switch versions anytime

๐Ÿ’ก Tip: For project-level control, use

pyenv local <version>