Как узнать установлен ли python на windows cmd

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

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

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

Очень важно знать, какая версия 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 на вашем компьютере поможет вам писать более эффективный код и избегать проблем совместимости.

To check the installed Python version in the command prompt (cmd), you can use the following command:

python --version

What is Python Versioning?

Understanding Python versioning is crucial for any developer or user working with the language. Python uses a version numbering system, typically denoted as major.minor.patch (e.g., 3.9.7). The major version indicates significant changes and backward-incompatible features, while the minor version adds functionality with backward compatibility. The patch version, on the other hand, fixes bugs within the existing features. Knowing which version you’re using can help ensure that your code is compatible with libraries and frameworks you wish to leverage, preventing unexpected errors in your projects.

How to Check JDK Version in Cmd: A Quick Guide

How to Check JDK Version in Cmd: A Quick Guide

Opening Command Prompt

To check the Python version using CMD, you’ll first need to open the Command Prompt on your Windows system. Here’s how to do it:

  1. Using the Search bar: Click on the magnifying glass in the taskbar, type «cmd,» and hit Enter. This will bring up the Command Prompt window.
  2. Using the Run dialog: Press the Windows key + R, type `cmd`, and hit Enter. This will open the Command Prompt window as well.

Command to Check Python Version

Once you have the Command Prompt open, you can execute the command to check Python version in cmd. The basic command to do this is:

python --version

or

python -V

What’s happening here? The `python` command invokes the Python interpreter, while the `—version` or `-V` flag requests the version information. After running this command, you can expect an output similar to:

Python 3.9.7

This output tells you that Python version 3.9.7 is currently installed on your system.

Alternative Commands

In some cases, you may need to point to the specific installation path of Python, especially if you have multiple installations. You can do this with the following command:

C:\Path\To\Python\python.exe --version

Here, replace `C:\Path\To\Python\` with the actual path where Python is installed on your computer. This command will yield the same version output, allowing you to verify the installation.

Another useful command is using the Py launcher, which can also manage multiple versions of Python. The command is simply:

py --version

Troubleshooting Command Errors

If CMD Says Python is Not Recognized

Sometimes, you might encounter an error stating that the command is not recognized. This usually means one of two things:

  • Python is not installed on your system.
  • Python installation is not added to the PATH environment variable.

To resolve these issues, consider the following steps:

  1. Installation Check: First, ensure that Python is installed. You can download and install the latest version from the [official Python website](https://www.python.org/downloads/).

  2. PATH Variable: If Python is installed but not recognized in CMD, you might need to add it to your PATH. To do this:

    • Open the Start Menu and search for «Environment Variables.»
    • Select «Edit the system environment variables.»
    • In the System Properties window, click the Environment Variables button.
    • Under System Variables, find the `Path` variable, select it, and click Edit.
    • Click New and add the path where Python is installed (e.g., `C:\Python39\` or `C:\Users\YourUser\AppData\Local\Programs\Python\Python39\`).
    • Save the changes and restart CMD.

Checking Multiple Versions

If you have multiple Python installations, you can find their locations using the following command:

where python

This command lists all the Python installations available in your PATH. This information helps in managing and switching between versions as per your project requirements.

Check Java Version in Cmd: A Quick Guide

Check Java Version in Cmd: A Quick Guide

How to Check Py Version in CMD

The Py launcher is beneficial, especially for users who frequently switch between different Python versions. The Py launcher allows you to check the version quickly using the command:

py -V

Similar to the previous commands, this will output your currently configured Python version, allowing for quick verification without needing to specify the installation path.

How to Check System Details in Cmd Quickly

How to Check System Details in Cmd Quickly

Examples to Illustrate the Commands

Example 1: Checking Python 3.x Version

Running the command:

C:\Users\User> python --version

You might see:

Python 3.9.7

This output confirms that Python 3.9.7 is the version currently associated with the `python` command.

Example 2: Using the Py Launcher

Another straightforward check can be performed with:

C:\Users\User> py --version

With expected output like:

Python 3.8.5

This indicates that the Py launcher is configured to point to Python version 3.8.5.

How to Run Python in Cmd: A Quick Guide

How to Run Python in Cmd: A Quick Guide

Conclusion

Knowing how to utilize the command to check the Python version in cmd is essential for anyone working with Python. Regularly verifying your version ensures compatibility with libraries and technologies, allowing you to leverage the full potential of Python in your projects. Keep your Python updated and explore additional CMD commands to enhance your skills in command-line management for a more efficient workflow.

How to Check Ping Through Cmd in a Snap

How to Check Ping Through Cmd in a Snap

Additional Resources

For more in-depth information, consider exploring:

  • [Official Python Documentation](https://docs.python.org/3/)
  • [Python Community Resources](https://www.python.org/community/)
  • Command Prompt troubleshooting forums for common CMD-related queries.

  1. Use the py Command to Check if Python Is Installed on Windows

  2. Use the py --version Command to Check if Python Is Installed on Windows

  3. Use the where Command to Check if Python Is Installed on Windows

  4. Use Python IDLE to Check if Python Is Installed on Windows

  5. Use the Control Panel to Check if Python Is Installed on Windows

  6. Check Python Installation in Visual Studio Code

  7. Conclusion

How to Check if Python Is Installed on Windows

Python is one of the most popular programming languages in the world and can be installed on most operating systems, be it Mac, Linux, or Windows. The discussion for this article is restricted to only Windows devices, though.

Before diving into Python programming on a Windows system, it is essential to ensure that Python is properly installed. This tutorial will explore multiple ways to check if Python is installed on Windows.

Use the py Command to Check if Python Is Installed on Windows

When we execute the py command in the Windows Command Prompt, it first displays the details of the latest version installed on the computer and then runs/starts the installed version.

If we need to check if some version of Python, i.e., Python 2 or 3, is installed, we can do so using the following command.

For Python 2.x:

For Python 3.7:

If the specified version of Python is not installed, the command will first return the not found error and then return all the installed versions of Python by the py launcher.

check if python is installed - not found

And if the py launcher is not installed, the following error will be returned.

check if python is installed - not recognized

Use the py --version Command to Check if Python Is Installed on Windows

We can also check what version of Python 2 or 3 is installed using the following command.

The above command will return the latest version installed on the computer and will not start it. We can also check if some specific version of Python is installed in the following way.

check if python is installed using py version 2

It will return the latest version of Python 2 installed on the computer. If the Python version specified in the command is not installed, like the py command, it will return all the versions installed on the computer.

check if python is installed - not recognized

Use the where Command to Check if Python Is Installed on Windows

The Windows where command searches and displays files in a directory tree. This command searches for the given pattern in the current directory and the paths specified in the PATH environment variable.

The where command is handy for locating the multiple versions of the same command in the PATH environment variable. So, if we look for python using the where command, it will return the paths of all the copies of python.exe.

check if python is installed using where

The where command will return the following error if Python is not installed on the computer.

check if python is installed using where 2

Use Python IDLE to Check if Python Is Installed on Windows

Python IDLE (Integrated Development and Learning Environment) is a user-friendly Python shell that comes bundled with the Python installation package.

Follow these steps:

  • Open Python IDLE: Press the Windows key, type IDLE, and select the Python IDLE option from the search results.
  • Check Python Version: In the Python IDLE shell, click on the Help menu and select About IDLE. A window will appear, displaying the installed Python version.

  • Verify Python Interpreter: In the Python IDLE shell, you can directly run Python code by typing print('Hello, World!') and pressing Enter. If Python is installed correctly, it will display Hello, World! as the output.

    check if python is installed using idle 2

Use the Control Panel to Check if Python Is Installed on Windows

Windows provides a convenient way to check installed programs through the Control Panel.

Follow these steps:

  • Open the Control Panel: Press the Windows key, type Control Panel, and select the Control Panel option from the search results.

    check if python is installed using control panel

  • Navigate to Programs or Programs and Features: You may find the desired option under different names depending on your Windows version.

    check if python is installed using control panel 2

  • Locate Python: Look for Python or Python X.X in the list of installed programs. If Python is present, it means it is installed on your system.

    check if python is installed using control panel 3

Check Python Installation in Visual Studio Code

Visual Studio Code (VS Code) is a popular code editor that supports Python development. You can also check if Python is installed within the VS Code environment.

Follow these steps:

  • Launch the VS Code editor on your Windows system.
  • If you haven’t already, install the Python extension for Visual Studio Code by going to the Extensions view (Ctrl+Shift+X) and searching for Python.
  • With a Python file open in Visual Studio Code, click on the bottom left corner where it displays the selected interpreter. It will show the installed Python versions. If you see a valid Python interpreter, it indicates that Python is installed.

    check if python is installed using vscode

Conclusion

Ensuring the correct installation of Python is necessary before proceeding with the coding journey. This article provided a step-by-step guide on how to check if Python is installed using various methods, including the Command Prompt, Python IDLE, Control Panel, and Visual Studio Code.

By following these steps, you can confidently verify the presence of Python on your Windows machine, enabling you to harness the power of Python and embark on your coding journey.

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe

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

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Disc drill для windows
  • Как убрать зеленые галочки с ярлыков в windows 10 на рабочем столе
  • Как на проигрывателе windows media включить субтитры
  • Закрепить панель задач windows 10 что это
  • Вирус который не дает переустановить windows 10