How to Install Python on Windows PC & Run Your First Hello World Program

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.

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.

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.

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.

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:

  1. Press Windows + S and search for “Environment Variables”.
  2. Click on “Edit the system environment variables”.
  3. In the System Properties window, click the “Environment Variables” button.
  4. Under “System variables”, find the one called Path.
  5. 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.

Download Python from the Official Website for your windows environment

  1. Open your web browser and go to the official Python website:
  2. https://www.python.org/downloads
  3. 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).
  4. Save the installer file to a location you can easily find, like your Downloads folder.

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).

Head to the official VS Code website: 👉 https://code.visualstudio.com

Click the Download for Windows button. This will download a .exe installer file.

  • Double-click the downloaded file to launch the setup wizard
  • Accept the license agreement
  • Choose the default installation location (or customize if you prefer)

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.

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
  • 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
  • Click File > New File
  • Save it as hello.py

Type this:

print("Hello, world!")
  • 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!

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.

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.

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.

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.

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\).

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.

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.

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.

  • 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

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.

  • 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.

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 just pip install.

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:bashpython script_name.py

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.

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:bashpip install module_name
  • Make sure you’re using the correct Python interpreter—especially if you have multiple versions installed.

Having both Python 2 and Python 3 installed on windows it can lead to unexpected behaviour.

How to fix it:

  • Use python3 instead of python if needed.
  • Check which version is running with python --version or python3 --version.
  • Consider uninstalling older versions if you don’t need them.

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.
  • 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.
windows

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top