How to Update Python

What you’ll build or solve

You’ll update Python to a newer version on your computer and confirm your terminal is using it.

When this approach works best

This approach works best when you:

  • Need features or fixes from a newer Python release for a course, library, or tool.
  • Hit install errors because a package requires a newer minimum Python version.
  • Want your system and editor to stop using an older Python that keeps showing up in the terminal.

Avoid this approach when:

  • You’re on a work-managed machine where updates require IT approval.
  • You have a production server without a planned upgrade and deployment process.

Prerequisites

  • A terminal: Command Prompt, PowerShell, or Windows Terminal on Windows, Terminal on macOS, any shell on Linux
  • Permission to install software on your machine

Step-by-step instructions

1) Check what Python you’re using now

Start by checking both the version and the path. This helps you spot multiple installs, which is the main reason updates “don’t work.”

python --version
python -c "import sys; print(sys.executable)"

On many macOS and Linux systems, python might not exist, so try:

python3 --version
python3 -c "import sys; print(sys.executable)"

What to look for: the sys.executable path. If it points to something you did not expect (Microsoft Store, Anaconda, Homebrew, pyenv), update that installation method instead of adding a second one. Mixing methods often leads to PATH conflicts where the old version keeps winning.


2) Update on Windows

Option A (most common): Use winget

Check that winget works:

winget --version

Install the newest Python version winget offers. Each minor version has its own winget ID (for example Python.Python.3.14), so pick the newest one from the search results:

winget search Python.Python.3
winget install --id Python.Python.3.14 -e

To get the latest patch release winget offers for a version you already have, upgrade its exact ID from winget list python. This stays within that minor version, for example 3.12.x:

winget list python
winget upgrade --id Python.Python.3.12 -e

Close and reopen your terminal so PATH updates apply, then verify:

python --version
py -V
py -c "import sys; print(sys.executable)"

What to look for: py comes from the Python install manager or the older Python Launcher. It often points at the newest Python even when python still points at an older one.

Option B (alternative): Use the Python install manager

Download the Python install manager from python.org, run it, and select Install. In a new PowerShell window, install or update to the newest Python:

pymanager install --update default

To update all runtimes the install manager installed, run pymanager install --update. If where.exe python shows an older standalone Python first, uninstall it (and Python Launcher, if listed) in Installed apps, or use Modify to turn off its PATH option. If you use the standalone installer instead, select Add python.exe to PATH during setup.

Verify in a fresh terminal:

python --version
where.exe python
py -c "import sys; print(sys.executable)"

What to look for: where.exe python can list multiple entries. The first path is usually what runs when you type python.


3) Update on macOS

Option A (most common): Use Homebrew

brew update
brew upgrade python

Verify:

python3 --version
which python3
python3 -c "import sys; print(sys.executable)"

What to look for: which python3 often shows a Homebrew path like /opt/homebrew/bin/python3 (Apple Silicon) or /usr/local/bin/python3 (Intel).

Option B (alternative): Use the official installer

Install Python from python.org, then verify:

python3 --version
which python3
python3 -c "import sys; print(sys.executable)"

If the terminal still uses an older version, another install (like Homebrew or pyenv) is probably earlier in your PATH.


4) Update on Linux

Linux updates depend on your distro. Many distros ship stable versions that can lag behind the newest release.

Option A (most common): Use your package manager

Ubuntu/Debian example:

sudo apt update
sudo apt install python3 python3-venv
python3 --version
python3 -c "import sys; print(sys.executable)"

If you need a specific newer version and your repos do not provide it, use pyenv.

Option B (alternative): Use pyenv for newer versions

After installing pyenv for your distro, install and select a version:

pyenv install 3.15
pyenv global 3.15
python --version
python -c "import sys; print(sys.executable)"

If pyenv says 3.15 isn’t a known version, update pyenv first: brew upgrade pyenv (Homebrew), git -C "$(pyenv root)" pull (git install), or pyenv update (pyenv.run installer).

What to look for: pyenv versions shows what’s installed, and pyenv which python shows which executable you’re running.


5) Recreate virtual environments for the new Python version

Updating Python does not update the packages inside your existing virtual environments. A venv is tied to the Python that created it, so the clean path is to recreate it.

Recreate the venv. --clear deletes everything in the old .venv, so if you don't have a requirements.txt yet, run python -m pip freeze > requirements.txt inside the old venv first. Then open a new terminal (or run deactivate) and check that python --version shows the new version. On macOS/Linux, use python3 instead of python.

# macOS/Linux
python3 -m venv --clear .venv

# Windows PowerShell
python -m venv --clear .venv

Activate it:

# macOS/Linux
source .venv/bin/activate

# Windows PowerShell
.\.venv\Scripts\Activate.ps1

Upgrade pip inside the venv:

python -m pip install --upgrade pip

Reinstall your dependencies:

python -m pip install -r requirements.txt

What to look for: if you keep an older .venv, you may see import errors or binary wheel issues after the Python update, even though the system Python looks correct.


6) Confirm the update worked

Run these checks in a new terminal window:

python --version
python -c "import sys; print(sys.version); print(sys.executable)"

If you rely on python3 instead of python, run the same checks with python3.


Examples you can copy

Example 1: Windows update with winget, then confirm what runs

winget list python
winget upgrade --id Python.Python.3.12 -e
python --version
where.exe python
py -c "import sys; print(sys.executable)"

Replace Python.Python.3.12 with the ID from winget list python. Use this to apply patch updates to the version you have, then confirm which Python runs. If python --version and py -V disagree, PATH order needs attention.

Example 2: macOS Homebrew update and PATH confirmation

brew update
brew upgrade python
python3 --version
which python3
python3 -c "import sys; print(sys.executable)"

Use this when you want the Homebrew-managed Python for development.

Example 3: Linux with pyenv for a specific version, plus a fresh venv

deactivate 2>/dev/null  # leave any active venv first
pyenv install 3.15
pyenv global 3.15
python --version
python -m venv --clear .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Use this when your distro packages are older than what your project needs.


Common mistakes and how to fix them

Mistake 1: Updating Python, but the terminal still shows the old version

What you might do: update Python, then run python --version and still see the older version.

Why it breaks: your shell is finding a different Python earlier in PATH.

Fix: find which Python is being used, then remove the conflict.

Windows:

where.exe python
py -V

macOS/Linux:

which python
which python3

Then uninstall the Python you do not want, or adjust PATH so the intended one appears first. On Linux, don’t remove the distro’s python3 (for example with sudo apt remove python3), because system tools depend on it. Adjust PATH or use pyenv instead.

Mistake 2: Keeping an old virtual environment after updating Python

What you might do: update Python, then keep using an existing .venv.

Why it breaks: the venv references an older interpreter and can include packages built for that older version.

Fix: recreate the venv and reinstall dependencies.

# delete the old .venv folder, then:
# macOS/Linux
python3 -m venv .venv
# Windows PowerShell
python -m venv .venv
# activate it, then:
python -m pip install -r requirements.txt

Troubleshooting

  • If you see python: command not found, use python3 --version instead. Many systems only provide python3.
  • If you see multiple results from where.exe python (Windows), the first path usually wins. Remove the extra Python install, or fix PATH order so the one you want comes first.
  • If you see Permission denied or externally-managed-environment when installing packages, install inside a virtual environment, not globally.
  • If pip installs to the wrong Python, always run pip through Python:
python -m pip install <package>
  • If your editor runs a different Python than your terminal, print the executable path in both places and select the same interpreter in your editor:
python -c "import sys; print(sys.executable)"
python3 -c "import sys; print(sys.executable)"

Quick recap

  • Check your current version and the executable path.
  • Update Python using one method that matches your setup.
  • Verify the new version in a fresh terminal.
  • Recreate your virtual environments, upgrade pip inside them, and reinstall dependencies.
  • If something still looks off, check PATH and confirm which executable is running.