$ python3 -c “import sys print(sys.version)” We can use sys.version to return a string containing the version of Python Interpreter with some additional information. The sys module in Python provides various functions and variables that are used to manipulate different parts of the Python runtime environment. In some environments, the Python2.x series is assigned to python command, and the Python3.x series is assigned to python3 command.Ĭheck Python version with sys module in Linux All you need is to open the terminal then type python -V in the prompt. To check Python version in Linux, you can use python -V command. python_version())”Ĭheck Python version in Linux with python -V command python3 -c “import platform print(platform.python3 -c “import sys print(sys.version_info)”.python3 -c “import sys print(sys.version)”.python3 –version or python -V or python -VV.The following commands can be used to get Python version in Linux. ![]() Many of its major features have also been backported to the backwards-compatible, though now-unsupported, Python 2.6 and 2.7. Python 3.0, a major, backwards-incompatible release, was released on Decemafter a long period of testing. For example, code written in Python 3.1.x will run with Python 3.10.x (which is the current Python version). However, minor releases are typically compatible with the previous releases. In other words, software written with Python version 2.x.x may not run correctly with Python 3.x.x. We must also note that major versions are typically not fully compatible with each other. ![]() The first digit represents the major version, the second the minor version, and the third digit represents the micro version or “revision level.”įor example, in Python 3.6.8, 3 is a major version, 6 is a minor version, and 8 is a micro version. Generally, Linux based distros have pre-installed Python version.īefore we can check what version of Python our computer has loaded, we must understand the version scheme of Python. Python is a high-level, general-purpose programming language created by Guido van Rossum. We will learn how to check the python version using the python command as well as how to determine the python version programmatically, from the python console and using python script. In this article, we will cover 3 ways to find the Python version in Linux. How to get the Python version on Linux is a commonly asked question during a Linux job interview.
0 Comments
Leave a Reply. |