banner



How To Know Which Version Of Python Is Installed

Introduction

Which version of Python do I accept installed?

Python is a pop programming language. Similar many other programming languages, there tin can exist several different versions organized by release engagement. Sure applications may require a specific version of Python.

In this tutorial, learn how to check the Python version on Windows, Linux, or macOS systems.

tutorial on how to check Python version.

Prerequisites

Access to a command-line/concluding window:

  • Linux:  Ctrl-Alt-T, Ctrl-Alt-F2
  • Windows:  Win+R > blazonpowershell> Enter/OK
  • MacOS:  Finder > Applications > Utilities > Last

There are dissimilar versions of Python, but the two near popular ones are Python 2.vii.ten and Python 3.seven.x. The x stands for the revision level and could modify as new releases come out.

When looking at the version number, there are unremarkably three digits to read:

  1. the major version
  2. the minor version
  3. the micro version

While major releases are non fully compatible, small-scale releases generally are. Version 3.6.1 should be compatible with three.seven.1 for case. The last digit signifies the latest patches and updates.

Python 2.7 and three.vii are unlike applications. Software that'southward written in 1 version often volition not work correctly in another version. When using Python, it is essential to know which version an application requires, and which version you have.

Python 2 volition stop publishing security updates and patches after 2022. They extended the borderline because of the large number of developers using Python ii.7. Python 3 includes a 2 to 3 utility that helps translate Python 2 code into Python 3.

How to Check Python Version in Linux

Most modern Linux distributions come up with Python pre-installed.

To check the version installed, open a concluding window and inbound the following:

          python --version        
python version linux

How to Check Python Version in Windows

Almost out-of-the-box Windows installations do not come with Python pre-installed. Nonetheless, information technology is always a good idea to check.

Open Windows Powershell, and enter the following:

          python --version        

If you take Python installed, information technology volition study the version number.

check python version windows

Alternately, apply the Windows Search function to encounter which version of Python you have:

Press the Windows key to commencement a search, then type Python. The organization will render whatsoever results that friction match. Most likely a match volition bear witness something similar to:

          Python 3.7 (32-chip)  app        

Or,

          Python ii.7 (32-fleck)  app        

This defines which major and minor revision (3.ten or 2.x) yous are using.

How to Check Python Version in MacOS

If using a MacOS, check the Python version by inbound the following command in the last:

          python -version        

The arrangement will report the version.

check python version macos

Annotation: In some cases, this will return a screen total of information. If that happens, just scan through the file locations for the word python with a number later on information technology. That number is the version.

Checking a System with Multiple Versions of Python

Python2 and Python3 are unlike programs. Many programs upgrade from the older version to the newer one. Nevertheless, Python two.vii.10 installations tin can be run separately from the Python 3.7.10 version on the same organization.

Python three is not entirely backward uniform.

To bank check for Python 2.7.x:

          python --version        

To check the version of Python three software:

          python3 --version        

Almost systems differentiate Python two as python and Python 3 as python3. If y'all do not take Python 2, your system may use the python command in place of python3 .

Annotation: Python does not have a born upgrade system. You'll need to download the latest version and install information technology.

How to Check Python Version in Script

When writing an application, information technology is helpful to have the software bank check the version of Python earlier information technology runs to prevent crashes and incompatibilities.

Employ the post-obit code snippet to check for the correct version of Python:

          import sys        
          if non sys.version_info.major == three and sys.version_info.minor >= vi:      print("Python 3.vi or higher is required.")      impress("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor))      sys.exit(1)        

When this script runs, information technology will test to come across if Python 3.6 is installed on the system. If non, it will transport a notification and displays the current Python version.

Conclusion

You lot should at present have a solid understanding of how to check for the version of Python installed in several unlike operating systems. Python is a powerful programming linguistic communication, thus it'southward important to sympathise its unlike versions.

If you want to learn how to upgrade Python to a newer version on Wondows, macOs, and Linux, check our article how to upgrade Python to iii.9.

Was this commodity helpful?

Aye No

Source: https://phoenixnap.com/kb/check-python-version

Posted by: greenequareatunto.blogspot.com

Related Posts

0 Response to "How To Know Which Version Of Python Is Installed"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel