How to Check if Python Is Installed on Windows
-
Use the
py
Command to Check if Python Is Installed on Windows -
Use the
py --version
Command to Check if Python Is Installed on Windows -
Use the
where
Command to Check if Python Is Installed on Windows - Use Python IDLE to Check if Python Is Installed on Windows
- Use the Control Panel to Check if Python Is Installed on Windows
- Check Python Installation in Visual Studio Code
- Conclusion
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.
And if the py
launcher is not installed, the following error will be returned.
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.
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.
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
.
The where
command will return the following error if Python is not installed on the computer.
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 thePython IDLE
option from the search results. -
Check Python Version: In the Python IDLE shell, click on the
Help
menu and selectAbout 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 displayHello, World!
as the output.
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 theControl Panel
option from the search results. -
Navigate to
Programs
orPrograms and Features
: You may find the desired option under different names depending on your Windows version. -
Locate Python: Look for
Python
orPython X.X
in the list of installed programs. If Python is present, it means it is installed on your system.
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 forPython
. -
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.
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.