Fix Python Version on macOS Using Pyenv
Thu Jan 08 2026

๐ 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โ EnterCtrl + 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>
