Checking python version windows

Содержание
  1. Как проверить версию Python
  2. How to Check Python Version
  3. В этом руководстве объясняется, как проверить, какая версия Python установлена ​​в вашей операционной системе с помощью командной строки. Это может быть полезно при установке приложений, которым требуется определенная версия Python.
  4. Версии Python
  5. Проверка версии Python
  6. Программная проверка версии Python
  7. Вывод
  8. note.nkmk.me
  9. Check the Python version on the command line: —version, -V, -VV
  10. Check the Python version in the script: sys, platform
  11. Various information strings including version number: sys.version
  12. Tuple of version numbers: sys.version_info
  13. Version number string: platform.python_version()
  14. How can I check all the installed Python versions on Windows?
  15. 2 Answers 2
  16. How To Check Python Version?
  17. Default Python Version
  18. python_version() Function
  19. version Variable
  20. Python –version Option
  21. Listing Python Interpreters
  22. HOW TO CHECK YOUR PYTHON VERSION
  23. Overview
  24. Environments
  25. Check Which Python Version in Script (Exact Steps)
  26. Check Python Version Jupyter (Exact Steps)
  27. Check Python Version Windows 10 (Exact Steps)
  28. Check Python Version Windows 7 (Exact Steps)
  29. Check Python Version Mac (Exact Steps)
  30. Check Python Version Linux (Exact Steps)
  31. Check Python Version Ubuntu (Exact Steps)
  32. Check Your Python Version in Anaconda (Exact Steps)
  33. Check Your Python Version in Spyder (Exact Steps)
  34. [History] What are the Different Python Versions?
  35. Python 3.0 – December 3, 2008
  36. Python 2.0 – October 16, 2000
  37. Python 1.0 – January 1994
  38. Python 0.9.0 – February 20, 1991
  39. How to Upgrade to a Newer Version?
  40. How to Check if Python 3 is Installed?
  41. How to Check Python Version – Detailed
  42. How to Make Sure My Script Runs a Specific Python Version?
  43. Summary
  44. Where to Go From Here?

Как проверить версию Python

How to Check Python Version

В этом руководстве объясняется, как проверить, какая версия Python установлена ​​в вашей операционной системе с помощью командной строки. Это может быть полезно при установке приложений, которым требуется определенная версия Python.

Python — один из самых популярных языков программирования в мире. Он используется для разработки веб-сайтов, написания сценариев, машинного обучения, анализа данных и многого другого.

Мы также покажем вам, как программно определить, какая версия Python установлена ​​в системе, где выполняется скрипт Python. Например, при написании сценариев Python вам необходимо определить, поддерживает ли сценарий версию Python, установленную на компьютере пользователя.

Версии Python

Готовые к выпуску версии Python имеют следующую версию:

Например, в Python 3.6.8 3 это основная версия, 1 дополнительная версия и 2 микро версия.

  • MAJOR — Python имеет две основные версии, которые не полностью совместимы: Python 2 и Python 3. Например, 3.5.7 , 3.7.2 , и 3.8.0 являются частью в Python 3 основные версии.
  • MINOR — Эти релизы приносят новые функции и возможности. Так , например, 3.6.6 , 3.6.7 и 3.6.8 являются частью минорной версии Python 3.6.
  • MICRO — Как правило, новые микро-версии содержат различные исправления ошибок и улучшения.

Разрабатываемые релизы имеют дополнительные классификаторы. Для получения дополнительной информации прочитайте документацию Python «Цикл разработки» .

Проверка версии Python

Python предустановлен в большинстве дистрибутивов Linux и macOS.

Чтобы узнать, какая версия Python установлена ​​в вашей системе, введите команду python —version или python -V :

Команда выведет версию Python по умолчанию, в данном случае, то есть 2.7.15 . Версия, установленная в вашей системе, может отличаться.

Версия Python по умолчанию будет использоваться всеми сценариями, которые /usr/bin/python установлены в качестве интерпретатора в строке сценария shebang .

В некоторых дистрибутивах Linux установлено несколько версий Python одновременно. Как правило, двоичный файл Python 3 называется python3 , а двоичный файл Python 2 — python или python2 , но это не всегда так.

Вы можете проверить, установлен ли Python 3, набрав:

Поддержка Python 2 заканчивается в 2020 году. Python 3 — это настоящее и будущее языка.

На момент написания этой статьи последний основной выпуск Python — это версия 3.8.x. Скорее всего, в вашей системе установлена ​​более старая версия Python 3.

Если вы хотите установить последнюю версию Python, процедура зависит от операционной системы, которую вы используете.

Программная проверка версии Python

Python 2 и Python 3 принципиально разные. Код, написанный на Python 2.x, может не работать в Python 3.x.

sys модуль , который доступен во всех версиях Python предоставляет параметры и функции системы конкретных. sys.version_info позволяет определить версию Python, установленную в системе. Это кортеж , который содержит пять номеров версий: major , minor , micro , releaselevel , и serial .

Допустим, у вас есть скрипт, который требует как минимум Python версии 3.5, и вы хотите проверить, соответствует ли система требованиям. Вы можете сделать это, просто проверив major и minor версии:

Если вы запустите скрипт, используя версию Python менее 3.5, он выдаст следующий вывод:

Чтобы написать код Python, который работает под Python 3 и 2, используйте future модуль. Это позволяет запускать Python 3.x-совместимый код под Python 2.

Вывод

Узнать, какая версия Python установлена ​​в вашей системе, очень просто, просто введите python —version .

note.nkmk.me

This article describes how to check and get the Python version installed and executed.

  • Check the Python version on the command line: —version , -V , -VV
  • Check the Python version in the script: sys , platform
    • Various information strings including version number: sys.version
    • Tuple of version numbers: sys.version_info
    • Version number string: platform.python_version()
    • Tuple of version number strings: platform.python_version_tuple()

If you get the version number in the script, you can not only display it with print() , but you can also switch the code to be executed depending on the version.

If you want to check the version of the package, OS, etc. instead of the version of Python itself, see the following articles.

Check the Python version on the command line: —version, -V, -VV

Execute the python or python3 command with the —version or -V option on the command prompt on Windows or the terminal on Mac.

As in the example above, in some environments, the Python2.x series is assigned to python command, and the Python3.x series is assigned to python3 command.

The -VV option has been added since Python 3.6. More detailed information than -V is output.

Check the Python version in the script: sys, platform

You can use the standard library sys module or platform module to get the version of Python that is actually running.

The same script can be used on Windows, Mac, and Linux such as Ubuntu.

It is useful for checking which version of Python is running in an environment where multiple versions of Python are installed. Even though you thought Python3 was running, there was a case where Python2 was running, so if something goes wrong, check it once.

It is also be used when you want to switch operation depending on whether it is Python2 or Python3.

Various information strings including version number: sys.version

sys.version is a string indicating various information including the version number.

sys.version
A string containing the version number of the Python interpreter plus additional information on the build number and compiler used.
sys.version — System-specific parameters and functions — Python 3.7.4 documentation

Tuple of version numbers: sys.version_info

sys.version_info is a tuple indicating the version number.

sys.version_info
A tuple containing the five components of the version number: major, minor, micro, releaselevel, and serial.
sys — System-specific parameters and functions — Python 3.7.4 documentation

releaselevel is str and the other elements are int .

Each value can be obtained by specifying an index.

From with version 2.7 for Python2 and from version 3.1 for Python3, elements can be obtained by name ( major , minor , micro , releaselevel , serial ).

For example, if you want to get a major version:

If you want to determine whether Python2 or Python3 is running, you can check the major version with this sys.version_info.major . 2 means Python2, and 3 means Python3.

An example of switching between Python2 and Python3 is as follows.

Use sys.version_info.minor if you want to switch by minor version.

As mentioned above, element access using names is supported from version 2.7 and version 3.1, so if there is a possibility that it will be executed in an earlier version, use sys.version_info[0] or sys.version_info[1] .

Version number string: platform.python_version()

platform.python_version() returns a string major.minor.patchlevel .

It is useful when you want to get the version number as a simple string.

Читайте также:  Puppy linux apt get

How can I check all the installed Python versions on Windows?

Please note I’m not asking «how to check which version of Python did I install».

I’ve installed several versions of Pythons on my Windows computer, for example Python 2.7-64, Python 2.7-32, and Python 3.7-32.

Python 3 includes «py» and «pyw» which helps me to easily start different Pythons, for example:

  • «py -2.7» starts Python 2.7-64
  • «py -2.7-32» starts Python 2.7-32
  • «py -3.7-32» starts Python 3.7-32

What I’m wondering is, how to check how many different versions of Python did I install on my Windows PC and what versions are they?

PyCharm is able to find it but, for one thing, I don’t know if it is a complete list, and for another, I wonder if there is any tool provided by Python or the operating system can do it.

2 Answers 2

I just got the answer. By typing «py -h» or «py —help» I got the help message:

Which tells me that «-0» (zero, not letter «O») lists the available pythons:

While «-0p» lists not only the versions, but also the paths:

If py -0p doesn’t work for you:

Solution

PowerShell: C:\> dir site.py -s -ErrorAction SilentlyContinue CMD: C:\>dir site.py /s

Citation

I found this workaround on Webucator and made some small adjustments for powershell.

Explanation

dir with the s parameter «lists every occurrence of the specified file name within the specified directory and all subdirectories» (Microsoft Docs).

How To Check Python Version?

Python is dynamic scriptin language which provides rich features. Python have two main version named Python version 2 and version 3. We can call them simply Python2 or Python3 . In this tutorial we will learn how yo check Python version or a script version.

Default Python Version

Every Python installation have a default version even there is two version of Python. If we can python command and enter to the check version.

Default Python Version

We can see from first line which is like Python 2.7.15rc1 which is simply Python2. We also get the gcc version which compiled this Python binary.

python_version() Function

Another function to check python version is python_version() function. But first we need to import platform module like below.

python_version() Function

version Variable

We can also use version variable which is provided by sys module.

version Variable

Python –version Option

Every Python interpreter supports the —version option in the command like below bash. We can call this option like below in order to learn default Python version.

OR to learn Python3 subversion

OR to learn Python2 subversion

Listing Python Interpreters

As Python 2 and 3 version there are different interpreters which provides Python programming language features. We can list these interpreters as files like below. We will use following ls command.

Listing Python Interpreters

HOW TO CHECK YOUR PYTHON VERSION

To check your Python version, run python —version in your command line (Windows), shell (Mac), or terminal (Linux/Ubuntu). To check your Python version in your script, run import sys to get the module and use sys.version to find detailed version information in your code.

Let’s get a quick overview of the different ways to check your Python version in all operating systems and environments. This may be all you need to know:

Commands Where? What? Example Output
python —version or
python -V or
python -VV
Terminal Mac/Linux/Win Python 3.7.2
import sys
sys.version
Python Script Information string ‘3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018,
23:09:28) [MSC v.1916 64 bit (AMD64)]’
sys.version_info Python script Version info tuple sys.version_info(major=3, minor=7, micro=2, releaselevel=’final’, serial=0)
import platform
platform.python_version()
Python script Short string info ‘3.7.2’
platform.python_version_tuple() Python script Short tuple info (‘3’, ‘7’, ‘2’)

Do you want to develop the skills of a well-rounded Python professional—while getting paid in the process? Become a Python freelancer and order your book Leaving the Rat Race with Python on Amazon (Kindle/Print)!

Table of Contents

Overview

When Guido van Rossum released the first viable Python version 0.9.0 in 1991, he couldn’t have expected (by a long shot) that he was on the verge of creating the most influential programming language in the world. Python has a bright future: every new Python version adds new features to the programming language.

In the following video and blog tutorial, I’ll show you how to check your Python version—no matter your operating system (Windows, macOS, Linux, Ubuntu) and programming framework (Jupyter). You can play the video while you scroll down to read the step-by-step instructions on how to check your Python version.

If you’re like me ten years ago, you need to Google important Python commands again and again. Fortunately, I found a simple and effective (and free) way to improve my Python skills. And so can you: learning with cheat sheets.

Join my email academy and download your free Python cheat sheets about various topics such as keywords, object-orientation, NumPy, and data structures.

Environments

This general method works across all major operating systems (Windows, Linux, and macOS).

OS & Environment Method
Win10, Win7 Open command line and run python -V or python —version
MacOS, Linux, Ubuntu Open terminal and run python -V or python —version
Python Shell, Juypter Notebook Interactive mode:
>>> import sys
>>> sys.version
Python Editor, Juypter Notebook Normal mode:
import sys
print(sys.version)

The table shows you how different environments call for different commands to check your Python version. You may have the following question:

How to open your command line or terminal?

  • Windows: Hit shortcut Win+R , type powershell , hit OK .
  • MacOS: Hit shortcut Cmd+Space , type terminal , hit OK .
  • Linux: Hit shortcut Ctrl+Alt+T .

The Python version output consists of three numbers major:minor:micro. For example, version 3.7.2 means that

  • the major version is 3,
  • the minor version is 7, and
  • the micro version is 2.

[ATTENTION] Different major versions are NOT fully compatible. Different minor versions are compatible.

For example, you can execute code written in Python 3.6.4 in Python 3.7.2 because they are the same major version — Python 3. But you cannot execute code written in Python 2.7.4 in Python 3.7.2 because they are different major versions.

Note that new minor versions can add changes to the language. For example, in Python 3.8 they introduced the reversed() function with dictionaries. You cannot use the reversed() function in older versions of Python. But the vast majority of the language is the same.

Before you move on to the exact steps you need to perform on your exact environment, please allow me to quickly present you my book “Coffee Break Python“. It uses the powerful puzzle-based learning method that helps you boost your rapid code understanding skills in Python.

Science shows that puzzle-based learning and practice testing improves learning retention by 44%.

Here’s an Amazon review of the book:

Feel free to check out the book if you’re an ambitious Python student and you want to reach advanced Python skill levels!

Let’s dive into the exact steps to check your Python version in any environment. I tried to figure out any environment you may be interested in. But if you don’t find yours, please let me know (chris at finxter dot com) and I’ll add your specific environment, too.

You can check out our interactive story to see how to check the Python version in different environments:

Click to move to next page!

Check Which Python Version in Script (Exact Steps)

Sometimes, you want to check Python’s version in your Python program.

To achieve this, simply import the sys module and print the sys.version attribute to your Python shell:

Check Python Version Jupyter (Exact Steps)

Three steps to check the Python version in a Jupyter notebook.

  1. Open the Jupyter notebook: type jupyter notebook in your terminal/console.
  2. Write the following Python code snippet in a code cell:

3. Execute the script.

As an alternative, you can also use the following Python code snippet to check your Python version in a Jupyter notebook:

Here is a screenshot on my computer:

Check Python Version Windows 10 (Exact Steps)

Three steps to check the Python version on your Win 10 operating system:

  1. Open the Powershell application: Press the Windows key to open the start screen. In the search box, type “powershell”. Press enter.
  2. Execute command : type python —version and press enter.
  3. The Python version appears in the next line below your command.

Check Python Version Windows 7 (Exact Steps)

Three steps to check the Python version on your Win 7 operating system.

  1. Open the command prompt application: Press the Windows key to open the start screen. In the search box type “command”. Click on the command prompt application.
  2. Execute command : type python —version and press enter.
  3. The Python version appears in the next line right below your command.

Check Python Version Mac (Exact Steps)

Four steps to check the Python version on your Mac operating system.

  1. Press CMD + Space to open Spotlight.
  2. Type “terminal” and press enter.
  3. Execute command : type python —version or python -V and press enter.
  4. The Python version appears in the next line below your command.

Check Python Version Linux (Exact Steps)

Three steps to check the Python version on your Linux operating system.

  1. Open the terminal application (for example, bash).
  2. Execute command : type in python —version or python -V and press enter.
  3. The Python version appears in the next line below your command.

Check Python Version Ubuntu (Exact Steps)

Four steps to check the Python version on your Ubuntu operating system.

  1. Open Dash: click the upper left symbol.
  2. Open terminal: type “terminal”, click on the terminal app.
  3. Execute command : type python —version or python -V and press enter.
  4. The Python version appears in the next line right below your command.

Do you need to google important Python keywords again and again? Simply download this popular Python cheat sheet, print the high-resolution PDF, and pin it to your office wall: 🐍

Check Your Python Version in Anaconda (Exact Steps)

You can choose from different alternatives.

  • To check your Anaconda version, run conda -V or conda —version in your anaconda prompt. You can open the anaconda prompt by searching for “anaconda prompt” in your OS’s search field.
  • An alternative to get your Anaconda version is to run conda list anaconda .
  • The shorter command conda list lists the name, version, and build details of your installed packages.
  • To learn about your environment details, run conda info with the optional flag –envs to see all your environments.
  • To check your Python version, run python -V or python —version in your terminal.

Related Material: Please find more detailed information about setting up your environment here. You can download an informative Anaconda cheat sheet here.

Check Your Python Version in Spyder (Exact Steps)

In your Spyder code editor, it’s even simpler to check your Python version. Just run any script and the version information will appear in the first line before the output of your script.

[History] What are the Different Python Versions?

Python has three main versions: version 1, version 2, and version 3. Version 4 is currently (2020) under development.

Here is the version history from Wikipedia and the official docs.

Python 3.0 – December 3, 2008

  • Python 3.8.2 ― released on 24 February 2020.
  • Python 3.8.1 ― released on 18 December 2019.
  • Python 3.8.0 ― released on 14 October 2019.
  • Python 3.7.7 ― released on 10 March 2020.
  • Python 3.7.6 ― released on 18 December 2019.
  • Python 3.7.5 ― released on 15 October 2019.
  • Python 3.7.4 ― released on 08 July 2019.
  • Python 3.7.3 ― released on 25 March 2019.
  • Python 3.7.2 ― released on 24 December 2018.
  • Python 3.7.1 ― released on 20 October 2018.
  • Python 3.7.0 ― released on 27 June 2018.
  • Python 3.6.10 ― released on 18 December 2019.
  • Python 3.6.9 ― released on 02 July 2019.
  • Python 3.6.8 ― released on 24 December 2018.
  • Python 3.6.7 ― released on 20 October 2018.
  • Python 3.6.6 ― released on 27 June 2018.
  • Python 3.6.5 ― released on 28 March 2018.
  • Python 3.6.4 ― released on 19 December 2017.
  • Python 3.6.3 ― released on 03 October 2017.
  • Python 3.6.2 ― released on 17 July 2017.
  • Python 3.6.1 ― released on 21 March 2017.
  • Python 3.6.0 ― released on 23 December 2016.
  • Python 3.5.8 ― released on 29 October 2019.
  • Python 3.5.7 ― released on 18 March 2019.
  • Python 3.5.6 ― released on 8 August 2018.
  • Python 3.5.5 ― released on 4 February 2018.
  • Python 3.5.4 ― released on 25 July 2017.
  • Python 3.5.3 ― released on 17 January 2017.
  • Python 3.5.2 ― released on 27 June 2016.
  • Python 3.5.1 ― released on 07 December 2015.
  • Python 3.5.0 ― released on 13 September 2015.
  • Python 3.4.10 ― released on 18 March 2019.
  • Python 3.4.9 ― released on 8 August 2018.
  • Python 3.4.8 ― released on 4 February 2018.
  • Python 3.4.7 ― released on 25 July 2017.
  • Python 3.4.6 ― released on 17 January 2017.
  • Python 3.4.5 ― released on 26 June 2016.
  • Python 3.4.4 ― released on 06 December 2015.
  • Python 3.4.3 ― released on 25 February 2015.
  • Python 3.4.2 ― released on 4 October 2014.
  • Python 3.4.1 ― released on 18 May 2014.
  • Python 3.4.0 ― released on 16 March 2014.
  • Python 3.3.7 ― released on 19 September 2017.
  • Python 3.3.6 ― released on 12 October 2014.
  • Python 3.3.5 ― released on 9 March 2014.
  • Python 3.3.4 ― released on 9 February 2014.
  • Python 3.3.3 ― released on 17 November 2013.
  • Python 3.3.2 ― released on 15 May 2013.
  • Python 3.3.1 ― released on 7 April 2013.
  • Python 3.3.0 ― released on 29 September 2012.
  • Python 3.2.6 ― released on 11 October 2014.
  • Python 3.2.5 ― released on 15 May 2013.
  • Python 3.2.4 ― released on 7 April 2013.
  • Python 3.2.3 ― released on 10 April 2012.
  • Python 3.2.2 ― released on 4 September 2011.
  • Python 3.2.1 ― released on 10 July 2011.
  • Python 3.2 ― released on 20 February 2011.
  • Python 3.1.5 ― released on 9 April 2012.
  • Python 3.1.4 ― released on 11 June 2011.
  • Python 3.1.3 ― released on 27 November 2010.
  • Python 3.1.2 ― released on 21 March 2010.
  • Python 3.1.1 ― released on 17 August 2009.
  • Python 3.1 ― released on 27 June 2009.
  • Python 3.0.1 ― released on 13 February 2009.
  • Python 3.0 ― released on 3 December 2008.

Python 2.0 – October 16, 2000

  • Python 2.7.17 ― released on 19 October 2019
  • Python 2.7.16 ― released on 02 March 2019
  • Python 2.7.15 ― released on 30 April 2018
  • Python 2.7.14 ― released on 16 September 2017
  • Python 2.7.13 ― released on 17 December 2016
  • Python 2.7.12 ― released on 26 June 2016.
  • Python 2.7.11 ― released on 5 December 2015.
  • Python 2.7.10 ― released on 23 May 2015.
  • Python 2.7.9 ― released on 10 December 2014.
  • Python 2.7.8 ― released on 1 July 2014.
  • Python 2.7.7 ― released on 31 May 2014.
  • Python 2.7.6 ― released on 10 November 2013.
  • Python 2.7.5 ― released on 15 May 2013.
  • Python 2.7.4 ― released on 6 April 2013.
  • Python 2.7.3 ― released on 9 April 2012.
  • Python 2.7.2 ― released on 11 June 2011.
  • Python 2.7.1 ― released on 27 November 2010.
  • Python 2.7 ― released on 4 July 2010.
  • Python 2.6.9 ― released on 29 October 2013.
  • Python 2.6.8 ― released on 10 April 2012.
  • Python 2.6.7 ― released on 3 June 2011.
  • Python 2.6.6 ― released on 24 August 2010.
  • Python 2.6.5 ― released on 19 March 2010.
  • Python 2.6.4 ― released on 25 October 2009.
  • Python 2.6.3 ― released on 2 October 2009.
  • Python 2.6.2 ― released on 14 April 2009.
  • Python 2.6.1 ― released on 4 December 2008.
  • Python 2.6 ― released on 1 October 2008.
  • Python 2.5.4 ― released on 23 December 2008.
  • Python 2.5.3 ― released on 19 December 2008.
  • Python 2.5.2 ― released on 21 February 2008.
  • Python 2.5.1 ― released on 18 April 2007.
  • Python 2.5 ― released on 19 September 2006.
  • Python 2.4.4 ― released on 18 October 2006.
  • Python 2.4.3 ― released on 29 March 2006.
  • Python 2.4.2 ― released on 28 September 2005.
  • Python 2.4.1 ― released on 30 March 2005.
  • Python 2.4 ― released on 30 November 2004.
  • Python 2.3.5 ― released on 8 February 2005.
  • Python 2.3.4 ― released on 27 May 2004.
  • Python 2.3.3 ― released on 19 December 2003.
  • Python 2.3.2 ― released on 3 October 2003.
  • Python 2.3.1 ― released on 23 September 2003.
  • Python 2.3 ― released on 29 July 2003.
  • Python 2.2.3 ― released on 30 May 2003.
  • Python 2.2.2 ― released on 14 October 2002.
  • Python 2.2.1 ― released on 10 April 2002.
  • Python 2.2p1 ― released on 29 March 2002.
  • Python 2.2 ― released on 21 December 2001.
  • Python 2.1.3 ― released on 8 April 2002.
  • Python 2.1.2 ― released on 16 January 2002.
  • Python 2.1.1 ― released on 20 July 2001.
  • Python 2.1 ― released on 15 April 2001.
  • Python 2.0.1 ― released on 22 June 2001.
  • Python 2.0 ― released on 16 October 2000.

Python 1.0 – January 1994

  • Python 1.6 ― released on 5 September 2000.
  • Python 1.5.2p2 ― released on 22 March 2000.
  • Python 1.5.2p1 ― released on 6 July 1999.
  • Python 1.5.2 ― released on 30 April 1999.
  • Python 1.5.1p1 ― released on 6 August 1998.
  • Python 1.5.1 ― released on 14 April 1998.
  • Python 1.5 ― released on 17 February 1998.
  • Python 1.4 ― released on 25 October 1996.

Python 0.9.0 – February 20, 1991

  • Python 0.9.1 ― released on February 1991
  • Python 0.9.2 ― released on Autumn, 1991
  • Python 0.9.4 ― released on December 24, 1991
  • Python 0.9.5 ― released on January 2, 1992
  • Python 0.9.6 ― released on April 6, 1992
  • Python 0.9.8 ― released on January 9, 1993
  • Python 0.9.9 ― released on July 29, 1993

As there are some significant differences in syntax, you should always install the latest version in Python. Keep yourself updated on the official Python website here.

How to Upgrade to a Newer Version?

If you are not using a virtual environment, go to python.org/downloads to download and install whatever version you need. It’s the easiest way to upgrade Python.

But now you’ll run into the following problem: how do I run a specific Python version? Check out this StackOverflow answer to learn the exact steps.

Or you can make your life easier by using virtual environments. These let you have multiple versions of Python installed on your system. Plus, you can switch between them instantaneously. One option is to use the built-in module venv. If you’re a Data Scientist, the industry standard is Anaconda.

Installing and upgrading different Python versions is easy when you use virtual environments. For a full tutorial of virtual environments, read over our introductory Finxter blog article.

How to Check if Python 3 is Installed?

If you’ve installed multiple installations of Python, running python —version may give you only the version of Python 2. To check which version of Python 3 is installed on your computer, simply run the command python3 —version instead of python —version .

How to Check Python Version – Detailed

Not only does Python have major, minor and micro versions. Each of those versions has further versions, namely the release level and serial.

These are displayed when you run

In the above code, I am running Python 3.8.0.

Most of the time, you will only care about the major, minor and micro releases. Release level and serial are usually for the core Python Dev team to work on changes to the language.

The possible release levels are ‘alpha’, ‘beta’, ‘candidate’, or ‘final’. Alpha contains the first updates made to the language. Beta means the language can be tested with some users but still won’t work perfectly. This is where the phrase ‘beta testers’ comes from. A ‘candidate’ has only a few small bugs left to fix. Final is the last version and the one released to the general public. If you want to try out new features before anyone else, you can download these release levels. However, if you just want a version of Python that works, you should choose ‘final’. When you download any version of Python, it will be a ‘final’ release unless stated otherwise.

Serial is for the smallest changes. The Python Dev team increments it as they make changes to the alpha, beta and candidate versions. All final versions have serial=0. They add future changes to the next major/minor/micro releases.

How to Make Sure My Script Runs a Specific Python Version?

Let’s say you’ve just installed Python 3.8. Your script, my_file.py , uses a brand new feature: reversed() when iterating over a dictionary. For other people to run this script, they must also run Python 3.8. So you should put a check at the start to let other users know this.

We do this by adding an assert statement at the top of my_file.py

The assert statement raises an AssertionError if the statement is False. If the statement is True, the script continues to run.

For example, if I am running Python 3.7 and execute my_file.py from the terminal, this happens

But if I am running Python 3.8, the assert statement does not raise an error, and it executes the rest of the script.

Note: I have used the Anaconda virtual environment to install and quickly switch between multiple Python versions.

Summary

Check the Python version by typing python —version in your operating system shell or command line. To get more detailed information about the environment your Python program runs in, try import sys; sys.version in your Python shell (interactive or normal mode).

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.

To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He’s author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.

His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.

Читайте также:  Fear для mac os
Оцените статью