How to Check and Verify the Version of Python on CentOS 6 / CentOS 7

Python is a widely used programming language that is installed on many Linux systems, including CentOS 6 and CentOS 7. Knowing which version of Python you have installed is important because different versions may have different features and capabilities. In this guide, we will show you how to check and verify the version of Python on CentOS 6 and CentOS 7.

Step 1: Check the Python Version

To check the version of Python that is installed on your CentOS system, open a terminal and run the following command:

python --version

This will display the version of Python that is currently installed on your system.

[root@vps ~]# python --version
Python 2.7.5

Step 2: Verify the Python Version

To verify that the version of Python you have installed is the one you want, you can open the Python interpreter and check the version. Run the following command:

python

This will open the Python interpreter. You should see a prompt that looks like this:

>>

Type the following command and press Enter:

import platform; print(platform.python_version())

This will display the version of Python that is currently being used by the interpreter.

See also  How to Enable APC With PHP on CentOS 6.3

If you have multiple versions of Python installed on your system, you can specify which version to use by running the appropriate command. For example, to use Python 3, you would run the following command:

python3

Commands Mentioned:

  • python –version – Check the version of Python installed
  • python – Open the Python interpreter
  • import platform; print(platform.python_version()) – Display the version of Python currently being used by the interpreter
  • python3 – Run Python 3

Conclusion

In this guide, we have shown you how to check and verify the version of Python on CentOS 6 and CentOS 7. By using these commands, you can ensure that you have the correct version of Python installed on your system and that you are using the version you want. If you have any questions or suggestions for improvements, please feel free to share them below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *