How do I update Python in the terminal?
Short answer: Install the new version from the terminal with your system's tool: py install 3.15 in Windows PowerShell, brew install python@3.15 in the macOS Terminal, or sudo apt install python3.15 on Ubuntu after adding the deadsnakes PPA. The latest release is Python 3.15.2. Then open a new terminal and check it with python --version on Windows or python3.15 --version on macOS and Linux. If the terminal still shows the old version, another Python comes first in your PATH: the fix is in the last section of this guide.
This guide covers only the terminal. For the installers from python.org and every other option, see the complete guide on how to update Python.
Updating Python from the terminal always has two parts: installing the new version and making your terminal run it. Most people get stuck on the second part, because the old version stays installed and keeps answering when you type python or python3.
On Ubuntu, python3 still runs the system version after the update. A virtual environment created with 3.15 makes python run the new version, and the same works in Windows PowerShell with py.
Terminal commands at a glance
| System | Terminal | Install the update | Check it |
|---|---|---|---|
| Windows | PowerShell or CMD | py install 3.15 | py -V:3.15 --version |
| macOS | Terminal (zsh) | brew install python@3.15 | python3.15 --version |
| Ubuntu | bash | sudo apt install python3.15 | python3.15 --version |
| Fedora | bash | sudo dnf install python3.15 | python3.15 --version |
| Any system | any | uv python install 3.15 | uv python list |
Step 1: check which Python your terminal runs
Before you update, find out which version answers and where it lives.
On macOS and Linux:
python3 --version
which -a python3On Windows, in PowerShell:
python --version
where.exe python
py listwhich -a and where.exe list every Python in your PATH, in order, and the first one is the one that runs. In PowerShell, type where.exe and not just where, which is a PowerShell shortcut for another command and prints nothing. To see the exact file of the Python you are using, run python3 -c "import sys; print(sys.executable)".
Update Python in the Windows terminal
Open PowerShell or Windows Terminal. python.org recommends the Python install manager, which works entirely from the terminal with the py command:
winget install 9NQ7512CXL7T -e --accept-package-agreements --disable-interactivity
py install 3.15
py listOpen a new terminal and check the result:
python --version
py -V:3.15 --versionpy install --update brings the versions you already have to their latest patch. py -V:3.15 runs that exact version, whatever the default is. If you use Chocolatey, choco upgrade python -y in PowerShell as administrator also works.
If python prints Python was not found; run without arguments to install from the Microsoft Store, Windows is running its own shortcut instead of your Python. Go to Settings > Apps > Advanced app settings > App execution aliases, turn off the two App Installer entries for python.exe and python3.exe, and open a new terminal.
Update Python in the macOS Terminal
With Homebrew:
brew update
brew install python@3.15
python3.15 --versionHomebrew installs the new version as python3.15. The python3 command can keep pointing to Apple's version or to another Homebrew Python, so call the new one by its full name or use a virtual environment, as explained below. Later, brew upgrade python@3.15 installs its new patches.
If you prefer pyenv to switch versions between projects:
pyenv install 3.15.2
pyenv global 3.15.2
python --versionIf pyenv is not installed yet, see what is pyenv and how to install it.
Update Python in the Linux terminal
On Ubuntu 22.04, 24.04 and 26.04, use the deadsnakes PPA:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.15 python3.15-venv
python3.15 --versionOn Fedora:
sudo dnf install python3.15
python3.15 --versionDo not point python3 to the new version with update-alternatives or a symbolic link. Your distribution uses the system python3 for its own tools, and changing it can break them: on Ubuntu, add-apt-repository is one of the first to fail. Call the new version as python3.15 or use a virtual environment.
Make the terminal use the new version
From most to least recommended:
- Create a virtual environment for each project. Inside it,
pythonis always the version you created it with:
python3.15 -m venv .venv
source .venv/bin/activate
python --versionOn Windows, create it with py -V:3.15 -m venv .venv and activate it with .venv\Scripts\activate.
-
Open a new terminal. A terminal reads the PATH when it starts, so a window that was already open keeps finding the old version. In bash and zsh,
hash -rmakes the current window forget the paths it remembered. -
Add an alias, on macOS and Linux. Add
alias python=python3.15at the end of~/.zshrcor~/.bashrcand runsource ~/.zshrc. It only changes what you type in your terminal, not your scripts or the system tools.
