banner



How To Find Out What Version Of Python I Have

Introduction

Which version of Python exercise I have installed?

Python is a pop programming language. Like many other programming languages, in that location can be several unlike versions organized past release appointment. Sure applications may require a specific version of Python.

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

tutorial on how to check Python version.

Prerequisites

Access to a command-line/terminal window:

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

There are different versions of Python, only the two nearly popular ones are Python 2.7.ten and Python 3.7.x. The x stands for the revision level and could alter equally new releases come out.

When looking at the version number, in that location are usually three digits to read:

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

While major releases are not fully compatible, minor releases generally are. Version 3.6.1 should exist compatible with iii.vii.i for example. The final digit signifies the latest patches and updates.

Python 2.vii and 3.seven are different applications. Software that'due south written in ane version ofttimes will not work correctly in some other version. When using Python, it is essential to know which version an awarding requires, and which version you lot have.

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

How to Check Python Version in Linux

Most modern Linux distributions come with Python pre-installed.

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

          python --version        
python version linux

How to Bank check Python Version in Windows

Most out-of-the-box Windows installations do not come with Python pre-installed. Even so, information technology is e'er a good thought to check.

Open Windows Powershell, and enter the following:

          python --version        

If y'all have Python installed, it will report the version number.

check python version windows

Alternately, employ the Windows Search function to see which version of Python you lot have:

Printing the Windows primal to outset a search, then blazon Python. The arrangement volition render whatsoever results that friction match. Most likely a match will bear witness something like to:

          Python three.7 (32-scrap)  app        

Or,

          Python 2.7 (32-bit)  app        

This defines which major and minor revision (3.ten or 2.10) you are using.

How to Cheque Python Version in MacOS

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

          python -version        

The organisation will study the version.

check python version macos

Note: In some cases, this will return a screen total of data. If that happens, just scan through the file locations for the discussion python with a number subsequently it. That number is the version.

Checking a System with Multiple Versions of Python

Python2 and Python3 are different programs. Many programs upgrade from the older version to the newer one. However, Python 2.7.x installations tin can exist run separately from the Python 3.seven.x version on the same organisation.

Python three is non entirely backward compatible.

To check for Python 2.seven.x:

          python --version        

To bank check the version of Python iii software:

          python3 --version        

Virtually systems differentiate Python 2 as python and Python 3 as python3. If y'all practice not have Python 2, your system may use the python command in place of python3 .

Notation: Python does non have a built-in upgrade system. You'll need to download the latest version and install it.

How to Check Python Version in Script

When writing an application, it is helpful to accept the software check the version of Python before it runs to foreclose crashes and incompatibilities.

Utilize the following code snippet to check for the correct version of Python:

          import sys        
          if not sys.version_info.major == 3 and sys.version_info.small-scale >= six:      print("Python iii.six or higher is required.")      print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.pocket-size))      sys.exit(1)        

When this script runs, it will examination to see if Python 3.half-dozen is installed on the arrangement. If non, it will send a notification and displays the electric current Python version.

Conclusion

You should now take a solid agreement of how to check for the version of Python installed in several dissimilar operating systems. Python is a powerful programming language, thus it's important to understand its different versions.

If you want to learn how to upgrade Python to a newer version on Wondows, macOs, and Linux, cheque our article how to upgrade Python to 3.ix.

Was this article helpful?

Yes No

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

Posted by: machadopriandn.blogspot.com

0 Response to "How To Find Out What Version Of Python I Have"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel