![]() ![]() (It's actually an arm v8) $ cat /etc/lsb-release My system is a Raspberry Pi 3B running Ubuntu: Linux mymachine 4.4.38-v7+ #938 SMP Thu Dec 15 15:22: armv7l armv7l armv7l GNU/Linux So I have had to leave it as defaulting to python 2 but I develop in python 3 and so would like my system to default to python 3 for when I run python and idle.Ĭan anyone tell me how I can achieve this without breaking apt? Press to keep the current choice, or type selection number: 1Īnd then apt worked again $ sudo apt remove python-samba Subprocess installed post-installation script returned error exit status 1Įrrors were encountered while processing:Į: Sub-process /usr/bin/dpkg returned an error code (1)Įventually I guessed it wanted python2 as the default, so I undid my changes as follows: $ sudo update-alternatives -config python ImportError: No module named 'ConfigParser' Subprocess installed pre-removal script returned error exit status 1įrom debpython.version import SUPPORTED, debsorted, vrepr, \įile "/usr/share/python/debpython/version.py", line 24, in įrom ConfigParser import SafeConfigParser ĭpkg: error processing package python-samba (-remove): 187285 files and directories currently installed.) The following package was automatically installed and is no longer required:Ġ upgraded, 0 newly installed, 1 to remove and 0 not upgraded.Īfter this operation, 5,790 kB disk space will be freed. Great! :) $ python -Vīut it wasn't long before I realised I had broken apt/aptitude when it comes to installing and removing python packages because apt was expecting python2 it transpired. Press to keep the current choice, or type selection number: 0Īnd that all worked. There are 2 choices for the alternative python (providing /usr/bin/python). $ sudo update-alternatives -config python $ sudo update-alternatives -install /usr/bin/python python /usr/bin/python3.5 3 So I did this: $ sudo update-alternatives -install /usr/bin/python python /usr/bin/python2.7 2 The below code shows a simple use of the sys.version to check the version.The other day I decided that I wanted the command python to default to firing up python3 instead of python2. ![]() 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 |