Getting Started with Python on Windows

Whether you're new to programming or an experienced coder, setting up Python on your Windows machine is the first step toward writing powerful Python code. This guide will walk you through the simple steps of installing Python on your Windows operating system and ensuring that everything is ready for your coding journey.


Step 1: Download Python Installer

The first step is to download the latest version of Python. Here's how:

  1. Visit the official Python website: https://www.python.org/downloads/.
  2. On the homepage, you'll see a "Download" button that automatically suggests the version for your operating system. Click the button to start the download.
  3. If you want a specific version of Python, you can go to the "Downloads" section and select the version manually.
official python downloads page

Step 2: Run the Installer

Once the installer has been downloaded, follow these steps:

  1. Locate the downloaded installer file, which will be named something like python-3.x.x.exe.
  2. Double-click the file to start the installation process.

Important:

  • Make sure to check the box that says "Add Python to PATH" at the beginning of the installation. This is a crucial step that will allow you to run Python from the Command Prompt easily.
  • Choose the "Install Now" option for a quick setup, or use the "Customize Installation" option if you want more control over the installation settings.
python add to path

Step 3: Verify Python Installation

  1. Open the Command Prompt. You can do this by searching for "cmd" in the Start menu or by pressing Win + R, typing cmd, and pressing Enter.
  2. Type the following command and press Enter:
    python --version
    If Python is correctly installed, you will see the version of Python displayed in the terminal, something like:
    python 3.x.x
  3. If you see an error or message that Python is not recognized, it may mean that Python was not added to your PATH during installation. You can manually add it or reinstall and ensure the box is checked during the installation.

Step 4: Install a Code Editor

To write and run Python code, you'll need a code editor. While you can technically use any text editor like Notepad, we recommend using a dedicated code editor to make development easier and more efficient.

One of the most popular choices is:

  • Visual Studio Code (VS Code): A lightweight, open-source code editor developed by Microsoft. It supports Python, includes debugging tools, Git integration, and many helpful extensions.

How to Install Visual Studio Code on Windows:

  1. Visit https://code.visualstudio.com and click the Download for Windows button.
  2. Once the installer is downloaded, double-click it and follow the on-screen instructions to complete the installation.
  3. After installation, open Visual Studio Code from your Start menu or desktop shortcut.
Visual Studio Code homepage

Install the Python Extension:

  1. Open VS Code.
  2. Click on the Extensions icon in the left sidebar (it looks like four squares).
  3. In the search bar at the top, type Python.
  4. Find the extension published by Microsoft and click Install.
  5. Once installed, VS Code will automatically detect your Python installation and provide suggestions for running and debugging Python code.
Python extension in VS Code

Step 5: Run Your First Python Script

Now that Python is installed, it’s time to write and run your very first Python program! Just follow these simple steps:

  1. Open your code editor (such as Visual Studio Code).
  2. Create a new file and name it something like hello.py. Make sure the file extension is .py, which tells the system it’s a Python script.
  3. In the new file, type the following code:
    python
    print("Hello, world!")
  4. Save the file to a folder you can easily find, like C:\Users\YourName\Documents or your Desktop.
  5. To run the script, you have two options:
    • In VS Code, click the Run (▶️) button at the top-right corner of the editor window.
    • Or, open the Command Prompt, navigate to the folder where your Python file is saved using the cd command, and run:
      python hello.py
  6. You should see this output:
    Hello, world!
  7. 🎉 Great job! You’ve just run your first Python program on Windows.

That's it! You’re all set to start coding in Python.
Happy coding!


Frequently Asked Questions

Do I need to restart my computer after installing Python?

In most cases, no. However, if Python doesn't show up in the command prompt after installation, try restarting your computer to ensure environment variables are properly set.


What does “Add Python to PATH” mean and why is it important?

Adding Python to your system PATH allows you to run Python from any terminal window. If you skip this step, you’ll have to manually navigate to Python’s installation folder to run scripts.


How do I open the Command Prompt?

Press Windows + R, type cmd, and hit Enter. Alternatively, search for "Command Prompt" in the Start Menu.


Why is my terminal showing an error when I type python?

This may happen if Python isn’t added to the PATH or if there’s a conflict with older Python versions. You can check your PATH settings or reinstall Python and make sure the box to add it to PATH is selected.


Can I install both Python 2 and Python 3 on my PC?

Yes, but it’s generally recommended to stick with Python 3 for modern development. If both versions are installed, you might need to use python3 instead of python in the terminal.


What if I want to uninstall or update Python later?

You can uninstall Python like any other program via the Control Panel under “Apps.” To update, download the latest installer and run it — it’ll offer to upgrade your current version.