How To Check If Multiple Python Versions Are Installed In Linux

When working with Python on a Linux system, it’s important to know which Python versions are installed and in use. This knowledge can help you solve compatibility issues, ensure specific features are available, and maintain a clean environment. In this tutorial, we will walk through the steps to check if multiple Python versions are installed in your Linux system.

Step 1: Check the default Python version

Open a terminal window and type the following command to check the default Python version:

The output will display the Python version as follows:

Python 3.8.5

You can also run the following command to check the default version of Python 3:

Step 2: Check for other installed Python versions

Next, we can check if there are other installed versions. Type the following command to list all the available Python executables in your system:

The output will be similar to this:


This example output shows that the system has Python 2.7, Python 3.6, and Python 3.8 installed.

Step 3: Use a specific Python version

If you need to use a specific Python version for a project or script, you can specify the version when running the script. For example, if you have a script named and you want to run it with Python 3.6, you can use the following command:

Step 4: Change the default Python version (Optional)

If you want to change the default Python version for your system, you can use the update-alternatives command. First, check the available alternatives by typing:

If no alternatives are listed, you can add the installed Python versions as follows:

Now, you can use the following command to change the default Python version:

Select the desired version from the list shown, and the default Python version will be updated.


In this tutorial, we went through the steps of checking for multiple Python versions installed in your Linux system and discussed how to change the default Python version. Knowing which Python versions are available and how to switch between them will help you maintain a productive development environment and avoid potential issues.