Как проверить версию python на windows

Last Updated :
22 Apr, 2025

Python has multiple versions, and it’s important to know which version is installed on your system. This information is crucial because different Python versions may have variations in syntax or libraries, and ensuring you’re using the correct version is vital for compatibility with your projects. In this guide, we’ll explore various straightforward methods on how to check the Python version on your Linux, Windows, and Mac systems.

How to Check Python Version on Windows and Mac

To check the Python version on Windows or Mac system, we can follow these methods:

  • Using the Command Prompt/Terminal
  • Checking in the Interactive Shell

Using the Command Prompt/Terminal

Open the Command Prompt for Windows by searching for “cmd” in the Windows Start menu or open Terminal for Mac by searching Terminal in the MacOS spotlight search.  Then, use one of the following commands:

For Python 2:

python –version
or
python -V

For Python 3:

python3 –version
or
python3 -V

pythonVersion

python Version using Command Prompt

Using Interactive Shell

We can also find the Python version in the interactive shell. Open the Command Prompt/terminal and enter one of the following commands:

For Python 2:

python

For Python 3:

python3

Once you are in the Python interactive shell, you can check the version with these Python commands:

import sys
print(sys.version)

pythonVersionUsingShell

Python Version Using Interactive Shell

How to Check Python Version on Linux

We can use the following methods to check the Python version on Linux systems like Ubuntu, Debian, Arch, etc. These methods can be used to find Python version:

  • Using the Command Line
  • Checking in the Interactive Shell
  • Using Package Managers
  • Checking the Path

Check the Python Version Using the Command Line

The command line provides a straightforward way to get the Python version. Open your terminal and use this simple check Python version command:

For Python 2:

python –version
or
python -V

For Python 3:

python3 –version
or
python -V

Checking python version in Linux

Check Python Version Using the Command Line

NOTE: These commands will display the Python version installed on your Linux system.

Check Python Version Using Interactive Shell

Python’s interactive shell is another way to find Python version. Open your terminal and enter one of the following commands:

For Python 2:

python

For Python 3:

python3

Once you are in the Python interactive shell, you can get Python version with the following Python commands:

import sys
print(sys.version)

Checking python version in Linux

Checking Python Version in the Interactive Shell

Check Python Version Using Package Managers

If you installed Python using a package manager, you can use these tools to check the Python version.

For Debian-based systems, such as Ubuntu, you can use `apt`:

apt show python3

Checking python version in Linux

Check Python Version Using Package Managers

For Red Hat-based systems, like CentOS, you can use yum:

yum info python3

NOTE: These commands will provide detailed information about the Python version installed on your system.

Finding Python Version by Checking the Path

We can also determine the path to the Python interpreter and indirectly obtain information about the installed version using the `which` command:

which python3

This command will return the path to the Python interpreter. We can then use this path to check the version:

/path/to/python –version

Replace ‘/path/to/python’ with the actual path obtained from the previous which command.

checking with path

Finding Python Version by Checking the Path

Also Read:

  • Download and Install Python 3 Latest Version
  • How to update Python on Windows?
  • How to Download and Install Python Latest Version on Linux

Пройдите тест, узнайте какой профессии подходите

Очень важно знать, какая версия Python установлена на вашем компьютере, особенно если вы работаете над проектом, который требует определенной версии.

Очень важно знать, какая версия Python установлена на вашем компьютере, особенно если вы работаете над проектом, который требует определенной версии. Версия Python может влиять на работу кода, так как разные версии могут иметь различные функции и библиотеки. Например, у вас может быть установлена версия Python 2.7, но вы хотите использовать функции, доступные только в Python 3.6. В этом случае вам нужно будет обновить Python до версии 3.6.

Освойте Python на курсе от Skypro. Вас ждут 400 часов обучения и практики (достаточно десяти часов в неделю), подготовка проектов для портфолио, индивидуальная проверка домашних заданий и помощь опытных наставников. Получится, даже если у вас нет опыта в IT.

Узнайте свою версию Python

Есть несколько способов узнать версию Python на вашем компьютере. Но самый простой и надежный из них — это использовать командную строку.

Для пользователей Windows

Откройте командную строку, нажав клавиши Windows + R, затем введите cmd и нажмите Enter.

В командной строке введите python --version и нажмите Enter. Система должна показать версию Python, установленную на вашем компьютере.

Для пользователей MacOS и Linux

Откройте Терминал.

В терминале введите python3 --version и нажмите Enter. Система должна показать версию Python, установленную на вашем компьютере.

На курсе Skypro «Python-разработчик» освоите основные инструменты программирования, получите опыт на реальных проектах и сможете стартовать в профессии уверенным новичком. Преподаватели — практикующие программисты с большим опытом, а в центре карьеры помогут составить цепляющее резюме и подготовиться к собеседованию.

Обновление Python

Если вы хотите обновить свою версию Python, вы можете скачать последнюю версию с официального сайта Python. Помните, что обновление Python может повлиять на некоторые из ваших существующих проектов, которые зависят от старых версий Python. Поэтому всегда рекомендуется создать резервную копию ваших проектов перед обновлением Python.

В любом случае, знание версии Python на вашем компьютере поможет вам писать более эффективный код и избегать проблем совместимости.

Введение

Python является одним из самых широко используемых языков программирования, поэтому разработчикам важно знать, какая версия установлена на их системе. Версия Python может повлиять на совместимость скриптов, библиотек и даже на поведение самого языка.

Проверка версии Python — это простая задача, но процесс немного отличается в зависимости от операционной системы. В Linux вы обычно используете терминал для проверки версии, в то время как в Windows вы можете использовать командную строку или непосредственно интерпретатор Python.

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

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

В Linux проверка версии Python быстрая и простая с использованием терминала. Ниже приведены различные методы, которые вы можете использовать для проверки, какая версия Python установлена на вашей системе.

Использование терминала

Версия Python по умолчанию

Чтобы проверить версию Python по умолчанию, просто откройте терминал и выполните следующую команду:

python --version

или

python -V

Эта команда вернет версию Python 2.x, если она установлена по умолчанию, что все еще актуально для некоторых старых дистрибутивов Linux.

Версия Python 3

На многих системах Linux установлены как Python 2, так и Python 3. Чтобы конкретно проверить версию Python 3, используйте следующую команду:

python3 --version

Это выведет версию Python 3.x, установленную на вашей системе.

Альтернативная команда

В некоторых дистрибутивах Linux команда python может быть связана с Python 3 вместо Python 2. В этом случае вы можете просто использовать следующую команду:

python --version

и она отобразит версию Python 3.

Использование интерпретатора Python

Если вы предпочитаете проверять версию из среды Python, вы можете сделать это, запустив интерпретатор Python.

  1. Откройте терминал.

  2. Введите python или python3 (в зависимости от версии, которую вы хотите проверить) и нажмите Enter:

    python
    
  3. Находясь в интерпретаторе, введите следующий код, чтобы проверить версию Python:

    import sys
    print(sys.version)
    
  4. Версия будет отображена в формате: 3.x.x (default, ...) или 2.x.x (default, ...).

  5. Выйдите из интерпретатора, введя:

    exit()
    

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

В Windows вы можете проверить версию Python через командную строку или интерпретатор Python. Вот как вы можете это сделать на машине с Windows:

Использование командной строки

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

Версия Python по умолчанию

Откройте командную строку, нажав Windows + R, введите cmd и нажмите Enter. Затем введите следующую команду:

python --version

или

python -V

Это выведет версию Python, установленную по умолчанию. Если установлены как Python 2, так и Python 3, будет показана версия по умолчанию, которая может быть либо Python 2, либо Python 3.

Если Python не найден

Если команда python не работает и терминал возвращает ошибку, что Python не распознан как внутренняя или внешняя команда, это означает, что Python либо не установлен, либо не добавлен в переменную PATH системы.

В этом случае вы можете проверить Python 3 с помощью следующей команды:

python3 --version

Эта команда работает, если Python 3 установлен и правильно настроен в вашем PATH.

Использование интерпретатора Python

Вы также можете проверить версию Python непосредственно из интерпретатора Python:

  1. Откройте командную строку (cmd).

  2. Введите python и нажмите Enter. Это запустит интерпретатор Python.

    python
    
  3. Находясь в интерпретаторе, проверьте версию, введя:

    import sys
    print(sys.version)
    

    Это отобразит полную версию Python вместе с некоторыми дополнительными деталями.

  4. Выйдите из интерпретатора, введя:

    exit()
    

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

Часто задаваемые вопросы

В: Что делать, если команда ‘python’ не распознается?

О: Если команда python не распознается, это, вероятно, означает, что Python либо не установлен, либо не добавлен в переменную PATH вашей системы.

  • На Windows убедитесь, что во время установки Python выбрана опция «Добавить Python в PATH». Если он уже установлен и не в PATH, вам может потребоваться вручную добавить каталог установки Python в переменную PATH вашей системы.

  • На Linux Python может вообще не быть установлен, или вы можете использовать дистрибутив, где Python 3 установлен как python3, а не python. Попробуйте использовать команду python3 --version.

В: Как проверить, установлены ли обе версии Python 2 и Python 3 на Linux?

О: На многих системах Linux установлены как Python 2, так и Python 3, но они могут быть доступны через разные команды:

  • Чтобы проверить Python 2, выполните:
    python --version
    
  • Чтобы проверить Python 3, выполните:
    python3 --version
    

Если обе версии установлены, вы увидите их соответствующие версии.

В: Могу ли я проверить версию Python из скрипта?

О: Да, вы можете проверить версию Python из скрипта. Для этого включите следующий код в ваш Python-скрипт:

import sys
print(sys.version)

Это выведет версию Python, используемую для выполнения скрипта, вместе с дополнительными деталями.

В: Как найти путь к исполняемому файлу Python?

О: Вы можете найти путь к исполняемому файлу Python, используя следующие команды:

  • На Linux:

    which python
    

    или

    which python3
    
  • На Windows:

    where python
    

Check Python Version – How to Check Py in Mac, Windows, and Linux

By Shittu Olumide

Python is a versatile and widely used programming language known for its simplicity and readability.

With its ever-evolving nature, different versions of Python are often released, each offering new features, enhancements, and bug fixes.

As a Python developer, it is crucial to be aware of the Python version you are using, as it determines the compatibility of libraries, syntax, and functionalities.

In this article, we will explore various methods to check the Python version installed on your system. Whether you are a beginner starting your Python journey or an experienced developer working on a project, knowing your Python version is the first step towards ensuring smooth execution and compatibility.

We will dive into the command-line approaches to determine the Python version. By the end of this article, you will be equipped with the knowledge to effortlessly check your Python version and make informed decisions regarding the tools and libraries you can utilize.

To check the Python version on a Mac, you can follow these steps:

Open the Terminal application on your Mac:

You can find the terminal by navigating to «Applications» -> «Utilities» -> «Terminal«, or by using Spotlight search (Cmd + Space) and typing «Terminal«.

Once the Terminal is open, you will see a command prompt where you can enter commands. Type the following command and press Enter:

python --version

This command will display the Python version installed on your Mac. For example, if you have Python 3.9.2 installed, it will display something like:

Python 3.9.2

The version number will vary depending on the specific Python installation on your system.

Alternative methods for Mac

If the python --version command does not work, try using the python3 command instead. Python 3 is the latest major version of Python, and some systems have both Python 2 and Python 3 installed.

To check the Python 3 version, enter the following command and press Enter:

python3 --version

This command will display the Python 3 version installed on your Mac.

Another way to check the Python version is by using the sys module within the Python interpreter. In the Terminal, type the following command and press Enter to start the Python interpreter:

python

This will launch the Python interpreter, and you will see a new prompt (>>>) indicating that you can enter Python commands.

Within the Python interpreter, type the following command and press Enter:

import sys
print(sys.version)

This will print the detailed Python version information, including the version number and additional details such as the build number and the date of the Python installation.

After checking the Python version, you can exit the Python interpreter by typing exit() and pressing Enter, or by pressing Ctrl + Z followed by Enter.

By following these steps, you will be able to check the Python version installed on your Mac using the Terminal application.

How to Check Python Version in Windows

To check the Python version on a Windows operating system, you can follow these detailed steps:

Open the Command Prompt:

  • Press the Windows key on your keyboard.
  • Type «cmd» (without quotes) in the search bar.
  • Click on the «Command Prompt» app from the search results. This will open the Command Prompt window.

Check if Python is installed:

In the Command Prompt window, type the following command and press Enter:

python --version

If Python is installed on your system, it will display the version number. For example, «Python 3.9.2«.

If Python is not installed, you will see an error message stating that the command is not recognized. In this case, you need to install Python before proceeding.

Verify the Python installation location (optional):

In the Command Prompt, type the following command and press Enter:

where python

This command will display the path of the Python executable file. By default, Python is installed in the «C:\PythonXX» directory, where «XX» represents the version number.

If the command doesn’t return any result, it means Python is not installed or not added to the system’s PATH environment variable.

Check the Python version using the Python interpreter:

In the Command Prompt, type the following command and press Enter:

python

This will launch the Python interpreter, displaying the Python version information at the top. For example, «Python 3.9.2 (tags/v3.9.2:1a79785, Feb 22 2021, 12:26:58)«.

To exit the Python interpreter, you can type exit() and press Enter.

Check the Python version using IDLE (optional):

IDLE is an integrated development environment that comes bundled with Python.

In the Command Prompt, type the following command and press Enter:

idle

This will launch the IDLE Python Shell, which will display the Python version information at the top. For example, «Python 3.9.2 (tags/v3.9.2:1a79785, Feb 22 2021, 12:26:58)«.

To exit the IDLE Python Shell, you can go to the «File» menu and choose «Exit» or simply close the window.

By following these steps, you can easily check the Python version installed on your Windows system using the Command Prompt or Python interpreter.

How to Check Python Version in Linux

Open a terminal:

Launch the terminal application on your Linux system. You can typically find it in the applications menu or by using a keyboard shortcut such as Ctrl+Alt+T.

In the terminal, type the following command and press Enter:

python --version

This command will display the Python version installed on your system.

Note: Some Linux distributions, such as Ubuntu, may have both Python 2 and Python 3 installed. In that case, the above command may display the version of Python 2. To check the version of Python 3, you can use the following command:

python3 --version

Check the output:

After executing the command, the terminal will display the Python version installed on your system. It will typically be in the format «Python x.y.z», where x, y, and z represent the major, minor, and micro versions respectively.

For example, the output might be:

Python  3.9.2


This means Python version 3.9.2 is installed on your Linux system.

### Verify the installation:

To verify that the Python version displayed is correct, you can also enter the Python interactive shell by typing the following command and pressing Enter:

```bash
python

This will open the Python shell, where you can interactively execute Python commands.

Check the version from the Python shell:

In the Python shell, you can confirm the version by typing the following command and pressing Enter:

import sys
print(sys.version)

The output will display detailed information about the Python version, including the version number, build information, and additional details.

Exit the Python shell

To exit the Python shell, you can type exit() or press Ctrl+D.

By following these steps, you can easily check the Python version installed on your Linux system.

Conclusion

By following the instructions provided in this article, you can easily check your Python version whether you use Mac, Windows, or Linux. This will help you write your Python programs confidently.

Remember to consult the relevant documentation or community resources if you encounter any issues or if you are using non-standard Python distributions or virtual environments.

As Python continues to evolve, staying updated with the installed Python version becomes increasingly important. This knowledge lets you to take advantage of new features and improvements introduced in newer Python releases while ensuring compatibility with existing codebases.

Let’s connect on Twitter and on LinkedIn. You can also subscribe to my YouTube channel.

Happy Coding!


Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

  1. Step 1 Откройте строку поиска.

    Если ее нет на панели задач, щелкните по значку лупы у

    Windows Start

    или нажмите Win+S.

  2. Step 2 Введите python в строке поиска.

    Откроются результаты поиска.

  3. Step 3 Нажмите Python [командная строка].

    Откроется черное окно командной строки с приглашением Python.

  4. Step 4 Найдите версию в первой строке.

    В левом верхнем углу окна отобразится слово «Python», а справа от него — версия Python (например, 2.7.14).

    Реклама

  1. Step 1 Откройте терминал.

    Для этого откройте окно Finder и нажмите «Программы» > «Утилиты» > «Терминал».

  2. Step 2 Введите python -V в терминале.

  3. Step 3 Нажмите ⏎ Return.

    Версия Python отобразится под словом «Python» (например, 2.7.3).

    Реклама

Об этой статье

Эту страницу просматривали 68 314 раз.

Была ли эта статья полезной?

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как узнать когда включали компьютер в мое отсутствие windows 10
  • Ваш выпуск windows 11 домашняя не поддерживает удаленный рабочий стол что делать
  • Kb982018 windows server 2008
  • Intel i211 driver windows server
  • Как подключить мобильный хот спот на windows 10