Upgrading the Python version to the latest is the easiest way to access the language’s new features, enhancements, and security improvements. Regardless of the platform you use for Python development, you should make sure you have the latest stable version to benefit from the latest language features.
Python 3.9 offers several improvements, stable components, and security for your projects.
In this tutorial, we will show you how to update Python to version 3.9 on Windows, macOS, and Linux.
How to Determine Your Python Version
Before upgrading to Python 3.9, you should find out the current version of your system. Fortunately, you can quickly find this information by running a couple of simple commands.
How to Verify Python Version on Windows
Launch the Command Prompt by pressing Win +R, entering cmd, and pressing Enter.
In the Command Prompt window, enter python –version.
The current Python version will be displayed underneath the command.
How to Check the Python Version on macOS and Linux
Follow these steps to verify the Python version currently installed on your macOS or Linux machines.
Launch the terminal app and enter python3 –version. Alternatively, you can use python3 -V.
How to Update to Python 3.9 on Windows, macOS, and Linux
Now that you know the current Python version on your machine, you can upgrade to Python 3.9. Note that the process uses different commands because of the differences among the underlying operating systems.
Let’s start with the prerequisites of the process.
Prerequisites
- A system running Windows, macOS, or Linux operating system
- Access to Powershell or the Command Prompt with administrator privileges on the Windows system.
- Access to the terminal on the Linux or macOS system
How to Update to Python 3.9 on Windows
You can upgrade to the latest Python version by opting for one of the following methods:
- Use the Official Python installer
- Use the Microsoft Store to install Python 3.9.
Method #1: Use the Official Installer to Upgrade to Python 3
Get the installer to update the Python version on your Windows machine by performing the following steps:
1. Visit the Windows section of the Downloads page on the official Python website to locate the Python 3.9 installer. Download the Installer.
2. Launch the installation file and follow the steps. If you are upgrading from an existing Python 3.x installation, you can use the installer to install the most recent version of Python alongside the older one.
Important: Remember to check the Add Python 3.9 to PATH box to add information about the new version to the PATH variables.
- When the installation wizard finishes, launch the Command Prompt (cmd) and check the Python version to confirm that the Python upgrade was successful.
Method #2: Install Python 3.9 from the Microsoft Store
Here are the steps to update Python through the Windows Microsoft Store.
- Search for Python on the Microsoft Store.
2. Select the Python version you wish to set up (Python 3.9, for example).
- Click Get (or Install) to start the installation process.
4. After the installation, Python will appear in the Start Menu.
- Next, type py.exe in the Command Prompt to launch the interactive Python mode.
How to Upgrade to Python 3.9 on macOS
You can opt for either of the following options to update Python on your macOS system to version 3.9.
Method #1: Use the Official Python Installer
Follow these steps to upgrade to Python 3.9 on your macOS system:
- Download the installer for Python 3.9 for macOS from the Download section of the official Python website.
2. Launch the installer to initiate the process.
- Agree to the license terms.
- During the installation process, select the Add Python to PATH option to modify the PATH environment variable on your system. Click Close to exit the installation wizard.
Method #2: Update Python Version Using Homebrew
Homebrew is a popular package manager on macOS for updating the packages on the system. Before following these steps, make sure Homebrew is installed and updated on the system. A well-liked package manager for Mac OS called Homebrew can make updating Python on your system easier. To update the Python version using Homebrew, follow these steps:
- Open the Terminal and run brew update to update Homebrew.
- To install Python 3.9, run brew install [email protected]. Homebrew will download and install the appropriate Python version.
- Use brew update python to upgrade the Python version.
How to Update to Python 3.9 on Linux
We’ll use the apt package manager to upgrade to version 3.9 on our Debian Linux machine. However, with appropriate changes, you can apply the following steps on your specific Linux distribution. 1. Launch the terminal and enter sudo apt-get update to update the package index.
2. Next, update the package index with the sudo apt-get upgrade command. During the process, the current Python version will be upgraded to version 3.9.
3. Execute the python3 – -version to verify that the upgrade was successful.
If you don’t have a current Python installation on your Linux system, you can install Python 3.9 by following these steps:
Launch the terminal and run the following command:
# add-apt-repository ppa:deadsnakes/pp
Upgrade the package index with the following command;
#apt-get upgrade
Now that the system is ready, run the following command to install Python 3.9:
#sudo apt install python3.9
Press Y to begin the installation when prompted.
How to Resolve the Issue of Seeing Previous Python Version After Installing Python 3.9
You might continue to see older Python versions after installing Python 3.9. Follow these steps to resolve this common issue.
- Run the following command to add the previous version to the list:
# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3-old 1
- Add the latest version (version 3.9.3 in our case) with:
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
- Next, enter the following command to set the versions’ priority status:
# sudo update-alternatives --config python3
- You can see the alternatives with a corresponding number. Make your choice and press Enter.
5 If you do not need the older versions, remove the symlink to the older Python 3 version.
# sudo rm /usr/bin/python3
- Finally, substitute the old version for the symlink:
# sudo ln -s python3.9 /usr/bin/python3
Now, check the default Python version with the following command:
# python3 --version
The output must verify that the most recent version was installed and configured successfully.
Why Should You Plan to Upgrade the Python Version?
Python 2 was the preferred version for developing applications before the release of Python 3.
Since Python 3 is not backward-compatible, developers upgraded to the new version to get the latest language features and security options. Since then, the Python team has been releasing major and minor versions to improve the language’s capabilities and improve the overall security of Python applications.
We highly recommend you upgrade to the latest Python version (version 3.9 in our case) to get these benefits and significantly improve your Python coding experience.
Conclusion
Maintaining a secure and effective development environment requires updating Python. By doing this, you’re assuring yourself access to the most recent features and improvements.
Upgrading Python allows you to utilize the community’s efforts to improve, secure, and enhance the language.
The recent Python versions offer enhanced memory management, quicker execution, and access to new routines and libraries. With every Python update, you might build more efficient and well-organized code.
If you’re looking for a robust server for your Python projects, RedSwitches offers the best dedicated server pricing and delivers instant dedicated servers, usually on the same day the order gets approved. Whether you need a dedicated server, a traffic-friendly 10Gbps dedicated server, or a powerful bare metal server, we are your trusted hosting partner.
FAQs
Q. How do I update Python to version 3.9?
To update Python to version 3.9, you can follow these steps:
- Go to the official Python website (python.org) and click on the “Downloads” section.
- Choose the version of Python 3.9 for your operating system (e.g., Windows, Ubuntu).
- Download the installer for Python 3.9.
- Run the installer and follow the on-screen instructions to install Python 3.9.
- Once the installation is complete, you can verify the version by opening a terminal or command prompt and typing python –version.
Q. How can I install Python 3.9 on Ubuntu 20.04?
With Ubuntu 20.04, you may use the following command to install Python 3.9:
# sudo apt install python3.9
On your Ubuntu machine, this command will download and install Python 3.9.
Q. How can I find out what Python version is currently installed?
You can open a terminal or command prompt and execute python –version to find out the version of Python that is currently installed on your machine. This will show you Python’s version number.
Q. How can I upgrade to the most recent version of Python?
Use the following instructions to update Python to the most recent version:
- Go to the “Downloads” section of the Python website (python.org) for official information.
- Find the most recent Python version compatible with your operating system.
- Download the most recent installation.
- To update Python, launch the installer and adhere to the prompts on the screen.
- After the upgrade, you can confirm the new version by typing python –version in a terminal or command prompt.
Q. How can I download the source code for Python 3.9?
To download the source code for Python 3.9:
- Visit the official Python website (python.org) and go to the “Downloads” section.
- Look for the “Source” link next to the version of Python 3.9.
- Click on the “Source” link to download the source code file.
- Once the download is complete, extract the source code from the downloaded file.
- You now have access to the Python 3.9 source code.
Q. What is pyenv?
Pyenv is a version management solution for Python that allows you to quickly switch between different Python versions on the same system.
Q. What security fixes are included in Python 3.9?
Python 3.9 includes important security fixes that enhance the safety and integrity of applications by addressing previous vulnerabilities.
Q. How has package management improved in Python 3.9?
Python 3.9 enhances package management with better compatibility and more stable dependency resolution, making it easier to maintain and update projects.
Q. What does “flexible function” refer to in Python 3.9?
The term “flexible function” in Python 3.9 refers to new syntax improvements that allow for more adaptable and efficient function declarations.
Q. Is Python 3.9 a stable version for enterprise use?
Yes, Python 3.9 is a stable version, recommended for enterprise use due to its robust features and enhanced performance optimizations.