![]() Next version for installing is the Python3.6 version. You should receive the following output python3.7 -V To check if the Python3.7 is installed successfully, run the following command: python3.7 -V Once, the repo is added and the system is updated, execute the command below: sudo apt install python3.7 -y Sudo add-apt-repository ppa:deadsnakes/ppa To install Python3.7, you need to add the repository first: sudo apt install software-properties-common Now we are going to install lower Python3 versions such as Python3.7, Python3.6 and Python3.5 In the previous steps we installed the default Python versions in Ubuntu 20.04, Python3.8, and Python2.7. You should get the following output: python3 -V To check if the Python3 version is installed successfully execute the command below: python3 -V To install the default Python3 version execute the following command: sudo apt install python3 -y You should get the following output: python2 -V To check if the Python2 version is installed successfully execute the command below: python2 -V To install the default Python2 version execute the following command: sudo apt install python2 -y In the first step of this tutorial we are going to install the default Python2 and Python3 versions in Ubuntu 20.04. sudo apt update -y & sudo apt upgrade -y Step 1. User privileges: root or non-root user with sudo privilegesīefore installing anything on your server it is recommended to update the system packages to their latest versions available.The below code shows a simple use of the sys.version to check the version. The second one uses the sys.version_info, which contains a tuple containing some python version info. The first uses the sys.version string, which contains some details like the python version, compiler version, etc. To get the version number using the sys library, we have two methods. These libraries are present in the python standard library, so we have no installation problem for these libraries. In this tutorial, we were using the sys and platform library. We have many modules that can help us to get the version of python. If f-string is supported, then continue with the code else, run some other code block. We can improve the program by checking the python version used programmatically and using the if/else condition to check whether f-strings are supported by the version. F-strings have been included in python in the 3.6 release, and so the code will work only on python version 3.6 or later. For example, assume you have written a python code that used f-strings for formatting strings. This technique has a benefit if our python program can be run only in a specified version. We can also use a python script to check which python version is used to run the script. If we write software using Python2, it will have some problems while running using the python3 interpreter.Ĭhecking python version in command line using –version parameter Using Python Script Still, the major releases were not compatible with each other. The python micro and minor releases are somewhat compatible, and a new version can run the same code without much problem. MICRO: The python micro releases contains many bug fixes and improvements.For example, python 3.7.x, python 3.8.x, etc. MINOR: These releases are bringing new functions, classes, features, etc.For example, python 3 has some subversions like 3.8.3, 3.4.5, etc. MAJOR: The Python programming language has two major releases that are not fully compatible with each other.The below list shows some more details about them. įor example, In Python Version 3.8.6, 3 is the major release(also known as python3), 8 is the minor release number, and 6 is the micro release number. The production-ready releases follow the below-shown syntax for versioning. The Python versioning contains three numbers to identify each release uniquely. Python uses the semantic versioning technique to give a version to its new release. Many Linux systems also have multiple Python versions installed we will also see how to know which versions are installed and how to use a particular version. This tutorial will see how to check the python version running on your Linux system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |