How to Check and Update Python Versions

How to Check Python Version?

Master Python Version Management From Beginner to Pro

Python is a high-level programming language that supports multiple functions such as structured, object-oriented, and functional programming. Python releases its updates on an annual basis that includes bug fixes and new features. It is important to understand that as a Python programmer, you should use the most updated version of Python for better performance and to increase productivity.

Upgrading the Python version to the latest on Windows and macOS simply can be done by downloading the installer from the official Python website and for Linux use deadsnakes/ppa , your apt-cache, and install the latest version with sudo apt install python3.x.

In this blog, we will go through the following steps and learn how we can check and update our Python version on Windows, macOS, and Linux.

  1. How to Check Python Version?
    1. How to Check Python Version on Windows?
    1. How to Check Python Version on macOS and Linux?
  2. How to Update Python Version on Windows?
    1. Utilizing the Python Installer
    1. Employing the Windows Microsoft Store
    2. By using Anaconda or Miniconda
  3. How to Update Python Version on MacOS?
    1. Updating Python with the Python Installer
    1. Employing Homebrew to Update Python
  4. How to Update Python Version on Linux?
  5. Closing Remarks

How to Check Python Version?

Before moving towards updating your python you should check the current version. We can check it by using some simple commands.

Let’s see how we can do that on different operating systems.

How to Check Python Version on Windows?

To check the Python version on Windows, you can follow these steps:

  1. Open the search bar and type cmd to launch the Command Prompt.
  2. Enter the command python --version and press Enter.
  3. You can observe that I am using the latest version of Python, which is 3.12.

How to Check Python Version on macOS and Linux?

Follow the steps given below to verify the current version of Python on Linux and macOS.

  1. Open the terminal window (Press Ctrl+Alt+T on Linux).
  2. After opening the terminal window, type python3 –version and press enter to see the current version of Python.
  3. Now you can see the current version of Python as shown below.

Now in the next section we’ll look at different processes to update Python to its latest version.

How to Update Python Version on Windows?

There are multiple different ways to update Python on Windows, listed below. We’ll go through each one by one.

  • By using Python installer.
  • By using Microsoft Store.
  • By using Anaconda or Miniconda.

Utilizing the Python Installer

Follow the instructions given below to update Python using Python installer.

  1. Visit Python’s official website.
  2. Download the latest version of Python as the latest version of Python is 3.12.0.
  1. After completing the downloading execute the installer.
  2. Do not forget to check the option Add Python to PATH.
  3. Click on Install Now and wait to complete the installation.
  1. After completing the installation, open the command prompt and verify the Python version using python –version.

Now you can use the improved version of Python powered with the latest features and bug fixes.

Using the Windows Microsoft Store

To upgrade Python to its latest version using the Windows Microsoft Store you can follow the steps below.

  1. Open the Microsoft Store and search for Python.
  1. Download the latest or your required version of Python.
  2. Click on the update button to initiate the process.
  3. Once the update is complete, open the command prompt and type python --version or python -V to check the version.

By using Anaconda or Miniconda

If you are using the Anaconda environment and want to update your Python, follow these steps to upgrade and ensure that you have the latest version of Python.

  1. Open the Anaconda command prompt from your start menu or use the search function to find it.
  2. Activate your specific environment using the command.
conda activate your_environment_name

In the above image you can see the activated environment and the current Python version is 3.11.6. Let’s update it to the latest.

  1. After activating your environment, use the following command.
conda update python
  1. After the update is complete, verify the installed Python version using the same command as shown below.

By following these steps, you can effectively update the Python version on Windows.

How to Update Python Version on MacOS?

We will update Python to the most recent version using two different methods, using the Python installer and using Homebrew. Let’s explore both methods.

Updating Python with the Python Installer

We will go through the following steps to update Python using the Python installer.

  1. Download the latest and most stable version of python3 from the official Python website.
  2. After completing the downloading, run the installer.
  3. Make sure to check the option “Add Python to PATH” to update your system’s PATH environment variable.
  4. When the installation is finished successfully, open the Terminal, and confirm the updated Python version using python3 –version.

By following these steps, we can easily update Python on your macOS system using the official Python installer, ensuring we have the latest features and improvements.

Employing Homebrew to Update Python

To update Python in macOS we can also use Homebrew which is a popular package manager for macOS. It simplifies the upgrading process. Follow these steps to update the Python version using Homebrew.

  1. Firstly install Homebrew if you don’t have it by following the instructions on the website.
  2. Open the terminal and update Homebrew and make sure to have the latest package information by using the following command.
brew update
  1. Upgrade the Python using Homebrew by following the command.
brew upgrade python
  1. Verify the Python version after completing the upgrade.
 python3 –version

By following any of these methods, we can update the Python version on our macOS. You can choose the best method according to your choice and existing setup.

How to Update Python Version on Linux?

In this section, you will learn how we can update on Linux operating systems. For this purpose, we will use APT package manager which is an important tool to manage software on Ubuntu and other Linux operating systems.

We will take the following steps using the APT package to update Python:

  1. Open the terminal window.
  2. Run sudo apt-get update to update packages.
  3. Now run sudo apt-get upgrade. This command will update the Python to its default version. The upgraded version may not be the latest. It is slightly behind the official release.
  4. Verify the updated version by running python –version.

By following these steps, you can update Python on your Linux operating system.

Closing Remarks

Using Python with the latest version is important for an effective development environment and to increase productivity. It helps you to write better code, make your program run faster and protect you from security bugs.

Author1

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments