How to Install Python on Windows - A Step-by-Step Guide

Python Install on Windows

In this article, we'll install Python on Windows step-by-step. First, we'll examine what is included in the installer, then we will install it using default settings and after it is done, we are going to test if the installation was successful. Finally, we'll end the tutorial by making a simple hello-world Python program.

Note: This article used Python 3.10.5 on Windows 10.

Let's look at what else is included in the Python installer before we start with the installation process.

What else can we install during Python installation

At the start of the installation process, if we select the "default installation", all of the tools and manuals mentioned below will be included and if we select "custom installation", we can choose what to include and what to skip.

Python Launcher

Python Launcher (py command in the terminal) is installed by default since Python 3.3. It is a tool that acts as a shortcut to all installed versions of Python available in the system and it allows scripts or command-line to specify a Python version and then it launches that version. More information about it can be found here.

Note: If you decide to uninstall Python from your System, Python Launcher will not be removed and you will have to uninstall it separately.

The pip command

The pip is a package manager for Python. We use it to install and manage packages and modules, mostly from the Python Package Index repository, but could also be used for other Python repositories, GitHub, the requirements.txt file of the project, and other sources.

Python IDLE Shell

Python IDLE (Integrated Development and Learning Environment) is a GUI Python interactive interpreter. It functions as a basic IDE editor. It has syntax highlighting, auto-completion, and debugging. More information about the IDLE is available here.

Python IDLE interpreter for Windows

Note: We can also use interactive interpreter inside the terminal (Command Prompt or PowerShell) by entering python command without parameters. To exit the interpreter, we can use either quit(), exit() or CTRL+Z.

Python Documentation

Python documentation will be included in the default installation. It will also include the documentation of the installed modules and packages in your system. When you install additional modules/packages with the pip command, those get included too.

Installing Python on Windows

In this section, we will install Python on Windows and then test it to see if it was successfully installed.

  1. Visit the Python official download website and click the Download Python button. On this page, we also have links for other platforms and different Python versions.

    Python download from the Python official website

  2. Save the file to your computer and run it. The Python Install window should appear.
    Python install - default installation

    First, check the box next to "Add Python 3.7 to PATH" as shown above. With this option enabled, you can run python commands anywhere from your computer.

    If we click on "Install Now" Python's default settings will be installed and should be fine in most cases. If you instead prefer custom installs, choose "Customize Installation".

  3. The User Account Control (UAC) window might appear and ask you if you want to allow this app to make changes to your device. Check that the Publisher is "Python Software Foundation" before clicking Yes.
    Python install - allow this app to make changes to your device

    The installation should now begin. Wait until the setup progress is completed.
    Python install progress

  4. In this step, we are giving the option to "Disable path length limit" as shown below. Click it, which will remove the Windows filesystem limitation of 260 characters.
    Note: Check this page if you want to learn more about Disable path length limit or if this installation step was not shown at all.

    Python install successful - disable path length limit

  5. After the installation is completed, we should get the "Setup was successful" message.
    Python install completed

Testing the Python installation

To see if Python was successfully installed, launch the command prompt (cmd) or PowerShell and run the following command:

python --version

This should return the Python version that is currently installed.

Python version in Windows command prompt

The python' is not recognized as an internal or external command error

If you get the message "'python' is not recognized as an internal or external command, operable program or batch file." it is possible you forgot to enable the checkbox for the Add Python 3.7 to PATH in the first step of the installation. We can fix this by going through the following steps:

  • Close the command prompt/PowerShell terminal.
  • Run the installer again (no need to uninstall)
  • Choose Modify
  • First, it will list "Optional Features". We are fine with what we installed, so click Next.
  • Next, it will list "Advanced Options". Enable the checkbox for the "Add Python for environment variables" and click Install.

Launch the terminal once more and try running the python --version command again.

Creating a simple hello-world script

Let's write a simple Python script that will display the hello world message. Create a hello.py file somewhere on your computer with the following code:

print("Hello World")

Inside the Command prompt/PowerShell, go to the location of the hello.py file and run the following command:

python hello.py

This should display the "hello world" on the terminal.

Note: We can use any text editor, but for anything more than simple scripts, I suggest to install VS Code editor.

Conclusion

In this tutorial, we learned how to install Python on Windows System. The Python installer also includes other tools and documentation that are automatically added with the default installation. We then tested if the Python was installed successfully and then created and ran a simple hello-world script.

Write a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.