Python gets updated roughly once per year with a major update and security fixes. So, Python’s update cycle is 12 months. The end-of-life, i.e., the period during which one Python version is supported, is normally set to 5 years.
The following graphic shows a great screenshot of supported and unsupported Python versions at the time of writing:
So, your Python version will become stale in a time period between 12 months and 5 years. In this article, you’ll learn how to update it!
Should You Update Python? General Tips for Win/Mac/Linux
Generally, you can install as many Python versions as you want on your operating system, no matter if you run Windows, macOS, Linux, or Ubuntu. To access a specific minor version 3.x
, you can run py -3.x
in your terminal or shell.
For example, to run Python 2.6 and Python 3.9, both being installed in your system, you’d run:
py -2.6 py -3.9
On my Windows machine, for example, I first tried running Python 3.8 by using py -3.8
but it told me it didn’t find it. However, it found Python 3.9 and 3.10 so I ran py -3.9
which opened the Python shell. See here:
So, should you update your Python version?
In most cases, you don’t need to update your Python version by means of updating your PATH environment variables etc. It’s usually enough to just install a new version of Python alongside the old version.
π Recommended Tutorial: How to install Python?
Okay, before we look at how to update Python, allow me to add a short section about how to check which version is installed in the first place. If you already know it in your case, feel free to scroll down and skip this section:
How to Check Python Version?
To check your Python version, run python ββversion
in your command line (Windows), shell (Mac), or terminal (Linux/Ubuntu).
python ββversion
To check your Python version in your script, run import sys
to get the module and use sys.version
to find detailed version information in your code.
import sys print(sys.version)
There are some more nuances to it, so please make sure to check out this tutorial to master this step if you experience any struggle:
π Recommended Tutorial: HOW TO CHECK YOUR PYTHON VERSION
Without further ado, here’s how you can update your Python installation on Windows:
How to Update Python in Windows?
To update your Python version on Windows, follow the steps as outlined next:
Step 1: Go to the official Python Windows Download page.
Step 2: Scroll down and download the latest stable release. In most cases, this will be “Windows Installer (64-bit)”.
Step 3: Wait for the download to complete and double-click to run the installer.
Step 4: Python will automatically detect if you’re trying to upgrade to a new version and it’ll prompt you with the suggestion “Upgrade Now” which you should click.
Step 5: Wait for the installation to finish up and you’re done!
You can now run the new Python installation on your computer by typing python
in your command line: the note at the top of the interactive shell will confirm that your new Python installation has been completed successfully.
If you have created virtual environments that depend on the old version, you can update the Python version in a specific virtual environment using the following command in your command line:
python -m venv ββupgrade <PATH TO YOUR VENV>
How to Update Python in macOS?
To update or upgrade your Python installation on your macOS, follow these three steps:
- Visit https://www.python.org/downloads/macos/ and download the installer.
- Run the installer and wait for it to terminate.
- Open your terminal and check your Python version with
python -V
.
Alternatively, you can use Homebrew (if installed) by running:
brew install python
That’s it! π
How to Update Python in Linux?
You can update Python on Linux or Ubuntu by using the apt
tool in three steps:
- Check which Python version is installed by running
python -V
in your terminal. - If you want to install a Python update, run the following two commands:
sudo apt update
sudo apt install python3.10
- Check which Python version is installed by running
python -V
in your terminal.
Conclusion
Thanks for spending your valuable time with Finxter! β€οΈ
This tutorial has shown you how to stay updated with your Python installation.
π§ Remember: Python ships a new release with security patches and all kinds of optimizations every couple of months! You need to get them to make sure you’re not missing out on functionality — and to keep your system secure and efficient.
If you want to keep learning and improving your Python skill and “upgrade your brain” regarding the latest developments in coding, feel free to register for our free email academy here: