How to Verify Python Installation on a Windows PC
If you’re new to Python and want to make sure it’s properly installed on your Windows computer, you’re in the right place. This guide will walk you through simple steps to check whether Python is installed, how to find its location, and what to do if it’s missing.
Open Command Prompt
To begin, open the Command Prompt. You can do this by pressing windows + R
, typing cmd
, and hitting Enter. Alternatively, you can search for “Command Prompt” in the Start menu and click on it.
Check the Python Version
Once Command Prompt is open, type the following command:
python --version
If Python is installed on your windows device, this command will return the version number, such as Python 3.11.5
. If you see an error message saying that 'python' is not recognized as an internal or external command
, it means Python might not be installed or the system doesn’t know where to find it.
You can also try:
py --version
This command works if Python was installed using the official Windows installer. It often succeeds even when python --version
fails, because py
is a launcher that comes bundled with the installer.
Locate Python on Your System
To find out where Python is installed, type:
where python
This command will show you the full path to the Python executable, such as:
C:\Users\YourName\AppData\Local\Programs\Python\Python311\python.exe
If nothing appears, Python might not be installed or the system path isn’t set correctly.
Check Environment Variables
If Python is installed it needs to be added in windows to your system’s PATH variable so Windows knows where to find it. To check this:
- Press
Windows + S
and search for “Environment Variables”. - Click on “Edit the system environment variables”.
- In the System Properties window, click the “Environment Variables” button.
- Under “System variables”, find the one called
Path
. - Click “Edit” and look for a path that includes something like
Python311
.
If you don’t see a Python path listed, it means Python wasn’t added to your PATH during installation.
What to Do If Python Is Missing
Download Python from the Official Website for your windows environment
- Open your web browser and go to the official Python website:
- https://www.python.org/downloads
- The site will automatically suggest the best version for your operating system. Click the “Download Python [version number]” button (e.g., Download Python 3.12.0).
- Save the installer file to a location you can easily find, like your Downloads folder.
Run the Installer
Once installation is complete, you’ll see a screen that says “Setup was successful.” You can optionally click “Disable path length limit” to avoid issues with long file paths.
Locate the downloaded .exe
file and double-click it to run the installer.
IMPORTANT: Before clicking “Install Now,” make sure to check the box that says: ✅ “Add Python to PATH” This ensures you can run Python from the Command Prompt later.
Click “Install Now” to begin the installation. The installer will set up Python and its associated tools (like pip
, the package manager).
How to Install Visual Studio Code on Windows
1. Download the Installer
Head to the official VS Code website: 👉 https://code.visualstudio.com
Click the Download for Windows button. This will download a .exe
installer file.
2. Run the Installer
- Double-click the downloaded file to launch the setup wizard
- Accept the license agreement
- Choose the default installation location (or customize if you prefer)
3. Select Additional Tasks
On the “Select Additional Tasks” screen, make sure to check:
- ✅ Add to PATH (important for terminal access)
- ✅ Register Code as an editor for supported file types
- ✅ Add “Open with Code” to Windows Explorer context menu
Click Install, and once it’s done, hit Finish to launch VS Code.
Set Up Python in VS Code
Install the Python Extension
- Click the Extensions icon on the left sidebar (or press
Ctrl+Shift+X
) - Search for Python
- Install the extension published by Microsoft
Select Your Python Interpreter
- Press
Ctrl+Shift+P
to open the Command Palette - Type and select “Python: Select Interpreter”
- Choose the version of Python already installed on your system
Write and Run Your First Python Program
Create a New File
- Click File > New File
- Save it as
hello.py
Write Your Code
Type this:
print("Hello, world!")
Run the Program
- Click the Run button at the top right
- Or right-click in the editor and choose Run Python File in Terminal
You should see:
Hello, world!
Common Issues and Troubleshooting for Python in VS Code
Python Not Recognized in VS Code
If you see errors like python: command not found
or Python is not installed
, it usually means VS Code can’t locate your Python installation anywhere in windows. Make sure Python is installed and added to your system’s PATH. In VS Code, open the Command Palette (Ctrl+Shift+P
) and select “Python: Select Interpreter”, then choose the correct version.
Python Extension Not Installed or Not Working
If you’re missing syntax highlighting, IntelliSense, or the “Run” button, the Python extension might be missing or malfunctioning. Go to the Extensions tab (Ctrl+Shift+X
), search for Python, and install the one published by Microsoft. If it’s already installed but acting up, try disabling and re-enabling it, or reinstalling VS Code.
Code Doesn’t Run in Terminal
If clicking “Run” doesn’t do anything or throws errors, check that your file is saved with a .py
extension. Make sure the terminal is using the correct Python interpreter. You can also run the file manually in the terminal using python hello.py
.
Multiple Python Versions Installed
Having more than one version of Python can cause confusion or unexpected behavior. Use python --version
and where python
in Command Prompt to see what’s installed. In VS Code, use “Python: Select Interpreter” to choose the correct one. If older versions aren’t needed, consider uninstalling them.
Missing or Broken PATH Variable
If Python works in VS Code but not in Command Prompt, your PATH variable might be misconfigured. Search for “Environment Variables” in Windows, edit the Path
variable under System Variables, and add the path to your Python installation (e.g., C:\Users\YourName\AppData\Local\Programs\Python\Python312\
).
pip Not Working
If you try to install a package and get 'pip' is not recognized...
, pip might not be installed or accessible. Run python -m ensurepip
to install pip, or use python -m pip install package_name
instead of just pip install
.
VS Code Terminal Not Responding
If the terminal freezes or doesn’t open, go to View > Terminal and click the trash icon to kill the terminal session. Restart VS Code, and if the issue persists, check for conflicting extensions.
Syntax Errors in Code
Red squiggly lines or error messages usually mean there’s a typo or formatting issue. Double-check your code for missing punctuation or inconsistent indentation—Python is very sensitive to whitespace.
General Tips for Troubleshooting
- Restart VS Code after installing extensions or changing settings
- Keep Python and VS Code updated to avoid compatibility issues
- Use the Output and Problems tabs in VS Code for detailed error messages
- Refer to official documentation when in doubt:
- Python Docs
- VS Code Python Extension
Common Python Issues and How to Fix Them
Python Not Recognized in Command Prompt
If you type python
in Command Prompt and get an error like 'python' is not recognized as an internal or external command
, it means Python isn’t added to your system’s PATH.
How to fix it:
- Reinstall Python and make sure to check the box that says “Add Python to PATH” during setup.
- Alternatively, manually add Python’s install directory to your PATH via Environment Variables.
pip Not Working
Trying to install packages and getting 'pip' is not recognized
? This usually means pip wasn’t installed or isn’t accessible.
How to fix it:
- Run
python -m ensurepip
to install pip. - Use
python -m pip install package_name
instead of justpip install
.
Python Script Doesn’t Run
If you double-click a .py
file and nothing happens, or it flashes and closes instantly, that’s expected behavior—Python scripts are meant to be run from a terminal or editor.
How to fix it:
- Open Command Prompt or VS Code’s terminal.
- Navigate to the folder containing your script and run:bash
python script_name.py
Syntax Errors
Python is very particular about formatting. Common mistakes include missing colons, inconsistent indentation, or using incorrect quotation marks.
How to fix it:
- Double-check your code for typos.
- Make sure indentation is consistent (use either spaces or tabs—not both).
- Use a code editor like VS Code that highlights syntax errors as you type.
Module Not Found Errors
If you try to import a module and get ModuleNotFoundError
, it means the module isn’t installed.
How to fix it:
- Install the module using pip:bash
pip install module_name
- Make sure you’re using the correct Python interpreter—especially if you have multiple versions installed.
Multiple Python Versions Causing Confusion
Having both Python 2 and Python 3 installed on windows it can lead to unexpected behaviour.
How to fix it:
- Use
python3
instead ofpython
if needed. - Check which version is running with
python --version
orpython3 --version
. - Consider uninstalling older versions if you don’t need them.
Virtual Environment Issues
If you’re using a virtual environment and packages aren’t recognized, you might not have activated it.
How to fix it:
- Activate your virtual windows environment before running your script:bash
.\venv\Scripts\activate
- Then install packages and run your code within that environment.
General Tips
- Always keep Python updated with windows to the latest stable version.
- Use a dedicated code editor like VS Code or PyCharm for better error visibility.
- Use virtual environments for project isolation—it prevents package conflicts.
- Refer to https://docs.python.org/3/ for official documentation.
