How to Upgrade Python to Version 3.9 On Windows, macOS, And Linux

Try this guide with our instant dedicated server for as low as 40 Euros

Update Python

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.

Table of Contents

  1. How to Determine Your Python Version
    1. How to Verify Python Version on Windows
    2. How to Check the Python Version on macOS and Linux
  2. How to Update to Python 3.9 on Windows, macOS, and Linux
    1. Prerequisites
  3. How to Update to Python 3.9 on Windows
    1. Method #1: Use the Official Installer to Update to Python 3
    2. Method #2: Install Python 3.9 from the Microsoft Store
  4. How to Update to Python 3.9 on macOS
    1. Method #1: Use the Official Python Installer
    2. Method #2: Update Python Version Using Homebrew
  5. How to Update to Python 3.9 on Linux
    1. How to Resolve the Issue of Seeing Previous Python Version After Installing Python 3.9
  6. Why Should You Plan to Update the Python Version?
  7. Conclusion
  8. FAQs

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.

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

python3vers1

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.

pyforwin-install

Important: Remember to check the Add Python 3.9 to PATH box to add information about the new version to the PATH variables.

add-path

  1. When the installation wizard finishes, launch the Command Prompt (cmd) and check the Python version to confirm that the Python upgrade was successful.

cmd-py-version

Method #2: Install Python 3.9 from the Microsoft Store

Here are the steps to update Python through the Windows Microsoft Store.

  1. Search for Python on the Microsoft Store.
    2. Select the Python version you wish to set up (Python 3.9, for example).

microsoft-store

  1. Click Get (or Install) to start the installation process.
    4. After the installation, Python will appear in the Start Menu.

startopt-py

  1. Next, type py.exe in the Command Prompt to launch the interactive Python mode. 

py-exe

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:

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

install-py-win

  1. Agree to the license terms.

license-agree

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

win-install-success

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:

  1. Open the Terminal and run brew update to update Homebrew.
  2. To install Python 3.9, run brew install [email protected]. Homebrew will download and install the appropriate Python version.

brew-install

  1. Use brew update python to upgrade the Python version.

brew-upgradepy

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.

python3vers1

 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

add-repo

Upgrade the package index with the following command;

#apt-get upgrade

apt-update

Now that the system is ready, run the following command to install Python 3.9:

#sudo apt install python3.9

Update Python

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.

  1. Run the following command to add the previous version to the list:

# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3-old 1

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

update-alt-install

  1. Next, enter the following command to set the versions’ priority status:

# sudo update-alternatives --config python3

update-alt-config

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

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

Also Read: How to Install Rust on Ubuntu 20.04/22.04

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:

  1. Go to the official Python website (python.org) and click on the “Downloads” section.
  2. Choose the version of Python 3.9 for your operating system (e.g., Windows, Ubuntu).
  3. Download the installer for Python 3.9.
  4. Run the installer and follow the on-screen instructions to install Python 3.9.
  5. 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:

  1. Go to the “Downloads” section of the Python website (python.org) for official information.
  2. Find the most recent Python version compatible with your operating system.
  3. Download the most recent installation.
  4. To update Python, launch the installer and adhere to the prompts on the screen.
  5. 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:

  1. Visit the official Python website (python.org) and go to the “Downloads” section.
  2. Look for the “Source” link next to the version of Python 3.9.
  3. Click on the “Source” link to download the source code file.
  4. Once the download is complete, extract the source code from the downloaded file.
  5. 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.

Try this guide with our instant dedicated server for as low as 40 Euros