Last modified: Aug 22, 2026
How to Update Python: A Simple Guide
Keeping Python updated is crucial for security and performance. New versions bring faster code and better features.
Updating Python might seem tricky, but it is straightforward. This guide shows you how to do it on all major systems.
We will cover Windows, macOS, and Linux. You will learn the best methods for each. Let's start with the basics.
Why Update Python?
Old Python versions stop receiving security patches. This puts your projects at risk.
Newer versions are significantly faster. Your code will run more efficiently after an update.
Many popular libraries require the latest Python. You cannot use them on older versions.
Updating also fixes bugs. You will encounter fewer errors in your daily coding.
Check Your Current Python Version
First, you need to know your current version. Open your terminal or command prompt.
Type the following command and press Enter:
python --version
Or, on some systems, you might use:
python3 --version
The output will look like this:
Python 3.9.6
This shows you are using Python 3.9.6. Now, you know what you are working with.
How to Update Python on Windows
Windows does not have a built-in package manager. You must download the installer manually.
Go to the official python.org website. Navigate to the Downloads section.
Click the button for the latest Python version. It will download an executable file.
Run the downloaded file. You will see the Python installer window.
Check the box that says "Add Python to PATH". This is very important.
Click "Install Now". The installer will update your Python version automatically.
After installation, verify the update. Open a new command prompt and type:
python --version
You should see the new version number. This confirms the update was successful.
How to Update Python on macOS
macOS often has a pre-installed Python. However, it is usually an older version.
The recommended way is to use Homebrew. It is a package manager for macOS.
First, install Homebrew if you don't have it. Open the Terminal and paste this command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, update it. Run this command:
brew update
Now, upgrade Python using the brew upgrade command. This will install the latest version.
brew upgrade python
This command handles everything for you. It updates the core Python and related tools.
Check the version after the process finishes:
python3 --version
You should see the latest Python release. Using Homebrew keeps things clean and simple.
How to Update Python on Linux
Linux distributions use different package managers. We will cover the two most common ones.
For Debian and Ubuntu, use APT. First, update your package list.
sudo apt update
Then, upgrade the Python package. This command is safe and straightforward.
sudo apt upgrade python3
For Fedora and CentOS, use DNF. The process is very similar.
sudo dnf upgrade python3
These commands update Python to the latest version in your distribution's repository.
Note that Linux repositories might not have the absolute latest version. They are often slightly behind.
For the newest version, consider using a tool like pyenv. It allows you to manage multiple Python versions easily.
Pyenv is helpful for developers. It lets you install and switch between different Python versions per project.
Handling Multiple Python Versions
Sometimes, you need more than one Python version. This is where pyenv becomes essential.
It is a version management tool. You can install it on macOS and Linux.
First, install pyenv using your package manager. On macOS, use Homebrew:
brew install pyenv
On Linux, you can use the installer script or your package manager.
Once installed, you can list all available Python versions. Use the pyenv install command to get a new one.
pyenv install 3.12.0
This installs Python 3.12.0. To make it your default, use the pyenv global command.
pyenv global 3.12.0
Now, your system uses the new version by default. This method is very flexible for developers.
Common Errors and How to Fix Them
You might encounter errors during the update. Here are some common ones.
If you see "Python is not found", your PATH is not set. Reinstall and check the "Add to PATH" box on Windows.
On macOS, you might get a "permission denied" error. Try using sudo before the command.
sudo brew upgrade python
If you have multiple versions, you might call the wrong one. Use python3 instead of python.
Sometimes, your shell caches the old path. Restart your terminal or run hash -r to clear it.
These small fixes solve most update problems. Always double-check your commands.
Update Your Virtual Environments
If you use virtual environments, you need to update them too. A virtual environment is tied to a specific Python version.
When you update the base Python, your old virtual environments might break. They still point to the old version.
The best practice is to create a new virtual environment. Then, reinstall your project dependencies.
First, delete the old environment folder. Then, create a new one with the updated Python.
python -m venv my_new_env
Activate it and install your requirements. This ensures your project uses the latest Python safely.
This process is a good habit. It prevents many compatibility headaches later.
Verify Everything Works
After updating, you must verify your code works. Run your main scripts to check for errors.
New Python versions might deprecate some older features. Your code might need small adjustments.
Use the python -m pip list command to see your installed packages. Check if they are compatible.
python -m pip list
If a package is incompatible, update it with pip install --upgrade package_name.
This final check ensures your development environment is healthy and ready to go.
Conclusion
Updating Python is a key skill for any developer. It keeps your projects secure and efficient.
We covered methods for Windows, macOS, and Linux. Each system has its own simple process.
Remember to check your version first. Then, use the appropriate package manager or installer.
For complex setups, use pyenv to manage multiple versions. Always verify your virtual environments after an update.
Now you know how to update Python confidently. Keep your development environment current and enjoy the new features.