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

winget search Python.Python.3
winget install Python.Python.3

If Python is already installed through winget, update it:

winget upgrade Python.Python.3

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 is the Windows Python Launcher. It often points at the newest Python even when python still points at an older one.

Option B (alternative): Use the official installer

Install the latest Windows version from python.org. During setup, select Add python.exe to PATH.

Verify in a fresh terminal:

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

What to look for: where python can list multiple entries. The first path is 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--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 install3.12.8
pyenv global3.12.8
python--version
python-c"import sys; print(sys.executable)"

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.

Update pip for the new Python first:

python-m pip install--upgrade pip

Create a fresh venv:

python-m venv .venv

Activate it:

# macOS/Linux
source .venv/bin/activate

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

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 upgrade Python.Python.3
python--version
where python
py-c"import sys; print(sys.executable)"

Use this when python --version looks wrong but py -V looks right. That usually means 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

pyenv install3.12.8
pyenv global3.12.8
python--version
python-m venv .venv
source .venv/bin/activate
python-m pip install--upgrade pip

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 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.

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:
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 python (Windows), the first path wins. Remove the extra Python install, or fix PATH order so the one you want comes first.
  • If you see Permission denied 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)"

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.
  • Update pip for the new Python.
  • Recreate your virtual environments and reinstall dependencies.
  • If something still looks off, check PATH and confirm which executable is running.