How to Update Python and Ruby on macOS 13
This guide provides a straightforward method for updating and
managing Python and Ruby environments on macOS 13 (Ventura). Because
macOS relies on internal system runtimes that should never be altered
directly, the standard and safest approach is to use Homebrew alongside
dedicated environment version managers—pyenv for Python and
rbenv for Ruby. Following these steps will allow you to
install, update, and switch between the latest versions without
disrupting operating system dependencies.
Prerequisites
Ensure you have Homebrew installed. If not, open Terminal and install it by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Make sure your Homebrew repositories are up to date:
brew updateUpdating Python on macOS 13
To manage multiple Python versions and update to the newest release,
use pyenv.
1. Install pyenv
Run the following command to install the version manager:
brew install pyenv2. Configure the Shell
Add pyenv to your Zsh shell profile so your system
automatically uses the active environment:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc3. Install and Set the Latest Python Version
View available versions, install your desired version, and set it globally:
# List available versions
pyenv install --list
# Install a specific version (example: 3.12.2)
pyenv install 3.12.2
# Set the installed version as the global default
pyenv global 3.12.2Verify the active version:
python --versionUpdating Ruby on macOS 13
To manage and update Ruby without conflicting with macOS system
binaries, use rbenv.
1. Install rbenv
and ruby-build
Install the environment manager and build definitions via Homebrew:
brew install rbenv ruby-build2. Configure the Shell
Set up rbenv shims in your ~/.zshrc
file:
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
source ~/.zshrc3. Install and Set the Latest Ruby Version
List the latest stable releases, install the version you need, and apply it globally:
# List available versions
rbenv install -l
# Install a specific version (example: 3.3.0)
rbenv install 3.3.0
# Set the installed version as the global default
rbenv global 3.3.0Verify the active version:
ruby -vKeeping Environments Updated
Whenever you need newer releases in the future:
- Update Homebrew formulas:
brew update && brew upgrade pyenv rbenv ruby-build - Install the new version:
pyenv install <version>orrbenv install <version> - Switch your environment:
pyenv global <version>orrbenv global <version>