4Geeks chosen to deliver AI education in the Bahamas alongside Harvard, Oxford, and Columbia.See more

How to update Python in Terminal?

By 4Geeks

The exact commands for PowerShell, the macOS Terminal and Linux, and how to make your terminal run the new version.

8 min readLast updated
Update Python in the terminal icon

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

SystemTerminalInstall the updateCheck it
WindowsPowerShell or CMDpy install 3.15py -V:3.15 --version
macOSTerminal (zsh)brew install python@3.15python3.15 --version
Ubuntubashsudo apt install python3.15python3.15 --version
Fedorabashsudo dnf install python3.15python3.15 --version
Any systemanyuv python install 3.15uv 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:

bash
python3 --version
which -a python3

On Windows, in PowerShell:

powershell
python --version
where.exe python
py list

which -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:

powershell
winget install 9NQ7512CXL7T -e --accept-package-agreements --disable-interactivity
py install 3.15
py list

Open a new terminal and check the result:

powershell
python --version
py -V:3.15 --version

py 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:

bash
brew update
brew install python@3.15
python3.15 --version

Homebrew 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:

bash
pyenv install 3.15.2
pyenv global 3.15.2
python --version

If 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:

bash
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.15 python3.15-venv
python3.15 --version

On Fedora:

bash
sudo dnf install python3.15
python3.15 --version

Do 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:

  1. Create a virtual environment for each project. Inside it, python is always the version you created it with:
bash
python3.15 -m venv .venv
source .venv/bin/activate
python --version

On Windows, create it with py -V:3.15 -m venv .venv and activate it with .venv\Scripts\activate.

  1. 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 -r makes the current window forget the paths it remembered.

  2. Add an alias, on macOS and Linux. Add alias python=python3.15 at the end of ~/.zshrc or ~/.bashrc and run source ~/.zshrc. It only changes what you type in your terminal, not your scripts or the system tools.

Career · AI Engineering

The terminal is where AI engineers work every day

From zero to junior AI Engineer: Python, AI agents and RAG with mentors and real projects.

Update Python from the terminal with AI

An AI assistant such as ChatGPT, Claude or GitHub Copilot is very good at reading terminal output. Give it your terminal, the version you have and the exact text you see. These three prompts are ready to copy.

1. Get the exact commands for your terminal

My terminal is [PowerShell on Windows 11 / zsh on macOS 15 / bash on Ubuntu 24.04].
python --version shows [3.12.4]. I want to update to Python 3.15 using only the terminal.
Give me the commands one by one, explain what each one does,
and tell me how to check that my terminal uses the new version.

2. Find out which Python your terminal runs

After installing Python 3.15, my terminal still shows [3.12.4].
This is the output of [which -a python3 / where.exe python]:
[paste the output]
Which Python runs first and why? Give me the safest fix,
without uninstalling anything or changing the system python3.

3. Understand an error

I ran this command in the terminal: [paste the command]
and got this error: [paste the full error]
My system is [system and version]. Explain what it means and how to fix it.

Read every command before you run it, especially the ones that use sudo or change your PATH or your ~/.zshrc.

Update pip and your packages from the terminal

pip does not update with Python: each version has its own pip and its own packages. To bring a project to the new version, save its packages with the old one and reinstall them in a virtual environment with the new one:

bash
python3.12 -m pip freeze > requirements.txt
python3.15 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

On Windows, use py -V:3.12 -m pip freeze > requirements.txt and py -V:3.15 -m venv .venv, and activate it with .venv\Scripts\activate.

On Ubuntu and Fedora, install packages only inside a virtual environment. Outside one, you will see No module named pip or error: externally-managed-environment, because the system protects its own Python.

You cannot update Python itself with pip: pip install --upgrade python does not work, because pip installs packages for a Python version but does not replace it.

Learn with a mentor

Master the terminal, then build AI with Python

In the 4Geeks AI Engineering career program you start with no experience and finish with AI agents and RAG systems in your portfolio.

Common errors when you update Python in the terminal

What you seeWhy it happensFix
python --version still shows the old versionThe old Python comes first in your PATH, or the terminal was already openOpen a new terminal, check which -a python3 or where.exe python, and use a virtual environment
Python was not found; run without arguments to install from the Microsoft StoreWindows runs its own shortcut instead of your PythonTurn off the App Installer aliases for python.exe and python3.exe in App execution aliases
command not found: python on macOS or LinuxYour system only has python3Use python3 or python3.15, or activate a virtual environment, where python exists
E: Unable to locate package python3.15The deadsnakes PPA is missing or the package list is not updatedRun sudo add-apt-repository ppa:deadsnakes/ppa and then sudo apt update
error: externally-managed-environmentYour system protects its Python from pipCreate a virtual environment and install your packages inside it
No module named pipThat version was installed without pipCreate a virtual environment with it: it comes with pip
ModuleNotFoundError in your projectThe packages are installed in the old versionReinstall them in the new one with python -m pip install -r requirements.txt
Free download

Every command to update Python in a 2-page cheat sheet

The terminal commands for Windows, macOS and Linux, how to check which version runs, how to move your packages, the most common errors and prompts for ChatGPT, Claude or Copilot. Free, in PDF.

Update Python cheat sheet: Windows, macOS and Linux

2 pages · PDF · 4Geeks

  • The update commands for PowerShell, the macOS Terminal, Ubuntu, Fedora and uv
  • How to check which Python your terminal runs
  • The 5 most common errors and prompts to fix them with AI

Get it free

Your PDF right away

Frequently asked questions about updating Python in the terminal

Want to go from the terminal to building AI agents, with real projects and mentors?

See the AI Engineering program