How to Update Python Version? (Upgrade Python Version)

Published on September 09, 2024, Updated on December 17, 2024

Python (py) is a versatile, open-source programming language that enables users to run commands, plugins, and software from various major providers on their machines. Its cross-platform capabilities allow it to operate on many operating systems, including Windows VPS Servers. Whether you're a beginner or an expert, our step-by-step guide on how to update Python version will help you master Python programming.

Pip, Python's package management system, is highly regarded for its ability to install and manage Python packages efficiently. Its popularity is due to the wide range of applications that utilize this tool. Pip simplifies the management of third-party packages with its easy-to-configure package manager. As the latest Python releases include pip by default, this guide will show you how to install pip and update your Python version with clear, step-by-step instructions. 

In this guide, we will guide you on how to update Python version on Windows, Mac OS and Linux. Follow along to learn how to upgrade your Python version efficiently.

HOW TO UPDATE PYTHON VERSION ON WINDOWS?

You can easily update your current Python version on Windows to the latest one using either of the following methods:

  1. Upgrade Python using the Python Installer
  2. Upgrade the Python version using the Windows Chocolatey Package Manager

Let's explore how to update your Python version using each of these methods step by step.

UPGRADE PYTHON USING THE PYTHON INSTALLER

This method for updating Python will work regardless of whether Python is currently installed on your system. If you already have Python installed, you can verify it by running the following command:

> python -V

STEP 1: DOWNLOAD THE PYTHON INSTALLER FROM THE OFFICIAL PYTHON WEBSITE 

The simplest way to update Python is to download the latest version from the official website

source: https://www.python.org/downloads/

Click the "Download Python 3.12.4" button to download the newest version compatible with your system.

STEP 2: RUN THE PYTHON INSTALLER 

Once the exe file has been downloaded, double-click on it to begin the Python installation process.

 

STEP 3: INSTALL PYTHON

You are now ready to install the latest version of Python on your system.

Make sure to check the "Add Python.exe to PATH" option, then click the "Install Now" button.

This will initiate the installation process, and once it's complete, the latest version of Python will be installed on your system.

Click on the Close button to complete the installation.

STEP 4: VERIFY UPDATE PYTHON VERSION

Once the installation is complete, you can verify that the latest version has been installed. To check, run the command python -V in the command prompt. You should see the latest version displayed, such as Python 3.12.4.

If the old version is still shown, try restarting your system or uninstalling the previous version from the control panel.

UPGRADE PYTHON VERSION USING THE WINDOWS CHOCOLATEY PACKAGE MANAGER

Chocolatey is a command-line package manager for Windows that can be used to install and update software, including Python.

STEP 1: LAUNCH POWERSHELL AS ADMINISTRATOR

Open PowerShell as Administrator To install Chocolatey, start by opening PowerShell with administrative privileges.

STEP 2: INSTALL THE CHOCOLATEY PACKAGE MANAGER

Next, install the Chocolatey package manager by executing the appropriate command:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

STEP 3: VERIFY CHOCOLATEY INSTALLATION 

To verify that Chocolatey has been installed successfully, execute the "choco" command.

You can confirm its successful installation if the command displays the Chocolatey version, such as Chocolatey v1.2.1.

STEP 4: UPDATE PYTHON USING CHOCOLATEY

To update your current Python version using Chocolatey, use the command:

> choco upgrade python -y

The above command will upgrade Python to the latest version available through Chocolatey.

STEP 5: VERIFY THE INSTALLED VERSION

To verify the latest installed Python version, use the command:

> python -V

The old version of Python may still be present on your system. If needed, you can uninstall the old version from the control panel.

HOW TO UPDATE PYTHON VERSION ON LINUX?

To upgrade Python version on a Linux server, follow these steps using the command line:

STEP 1: ADD THE DEADSNAKES PPA

Add the DeadSnakes PPA to your system's software sources to access newer and unsupported Python versions.

$ sudo add-apt-repository ppa:deadsnakes/ppa

This step allows you to install Python versions not available in the default repositories.

STEP 2: UPDATE PACKAGE LISTS

Update the package lists to retrieve information about the latest versions of available packages.

$ sudo apt update

This ensures that you have the most current information about available packages.

STEP 3: INSTALL PYTHON ON LINUX

Install the desired Python version. For example, to install Python 3.11, use:

$ sudo apt install python3.11

Replace python3.11 with the version you want to install, such as python3.12 for Python 3.12.

STEP 4: VERIFY INSTALLED VERSIONS

After installation, you can verify the versions of Python installed on your system using these commands:

Check the default Python version:

$ sudo python --version

This typically shows the default Python 2.x version.

Check the Python 3.x version:

$ sudo python3 --version

This shows the default Python 3.x version, such as Python 3.11.x.

Check the specific version installed (e.g., Python 3.11):

$ sudo python3.11 --version

This confirms the installation of Python 3.11.0 or the specific version you installed.

The above steps allow you to effectively update and verify Python versions on your Linux system.

HOW TO UPDATE PYTHON VERSION ON MAC OS?

To upgrade Python version on macOS to the latest version, follow these steps similar to updating on Windows:

STEP 1: DOWNLOAD AND INSTALL PYTHON

Visit the official Python website and download the latest version for macOS. Follow the installation instructions to complete the setup.

STEP 2: CHECK PYTHON VERSION

After installation, verify the Python versions installed on your system using these commands:

To check the default Python 2.x version:

$ python --version

To check the default Python 3.x version (e.g., Python 3.11.0):

$ python3 --version

STEP 3: SET ALIAS FOR PYTHON COMMAND

Optionally, if you prefer using Python instead of python3 to execute the latest Python release, you can set an alias in your .bash_profile file. To do this, open Terminal and navigate to your home directory:

$ cd $HOME

Edit .bash_profile using a text editor like Nano:

$ nano .bash_profile

Add the following line at the bottom of the file:

alias python="python3"

Save and close the file (in Nano, press Ctrl + X, then Y, and Enter).

STEP 4: VERIFY ALIAS

After adding the alias, verify that the Python --version now displays the Python 3.x version, such as Python 3.11.0.

These steps allow you to update and manage Python versions on macOS, ensuring you have the latest version installed and configured as desired.

WHAT ARE THE BENEFITS OF UPGRADE PYTHON VERSION?

Here are the key reasons why upgrading Python is beneficial:

  1. Performance Improvements: Each new version includes optimizations that can make your code run faster and more efficiently.
  2. Security Enhancements: Upgrading ensures you receive patches for vulnerabilities, keeping your applications secure.
  3. New Features: Newer versions introduce useful features and syntax improvements for more effective coding.
  4. Library Compatibility: Many third-party libraries prioritize compatibility with newer Python versions, giving you access to their latest features.
  5. Deprecated Features: Upgrading helps avoid issues with functions and features that are phased out in older versions.
  6. Bug Fixes: New releases address bugs to improve stability and reliability.
  7. Extended Standard Library: Updates expand Python's built-in modules and functions, offering more tools for development.
  8. Type Hints: Enhanced type hinting supports better code clarity and error checking.
  9. Concurrency Support: Improved capabilities for concurrent and parallel programming enhance application performance.
  10. Long-term Support: Using supported versions ensures ongoing updates and community support.
  11. Consistency: Upgrading maintains consistency across development teams, reducing compatibility issues.

Before upgrading, always test compatibility with your existing code and dependencies to minimize disruption.

CONCLUSION

We explained in this guide how to update Python Version across different operating systems—Windows, macOS, and Linux—it's clear that following the outlined guides ensures a successful installation of the latest version.

 We trust that this comprehensive guide meets your needs effectively. Should you have any feedback or questions, please feel free to leave them in the comments section below. Your input is valuable as we strive to provide the best possible assistance for updating your Python software.

Are you looking for a reliable host for your VPS or a dedicated server? Host World offers top-quality VPS, dedicated server hosting, and SSL services globally. With hardware in 17 countries, we ensure maximum availability and 99.9% uptime. Our rapid 10-minute response time and multilingual support ensure efficient and reliable technical assistance for your business, keeping you online without interruption.