How to Install Python on Windows

December 5, 2023

Introduction

Python is a widely used high-level programming language. It is one of the most popular and flexible server-side programming languages.

Windows does not have the Python programming language installed by default. However, you can install Python on Windows in just a few easy steps.

This guide provides step-by-step instructions to install and set up Python on Windows.

How to Install Python on Windows 10

Prerequisites

Python Installation on Windows

The installation requires downloading the official Python .exe installer and running it on your system. The sections below will explain several options and details during the installation process.

Step 1: Select Python Version

Deciding on a version depends on what you want to do in Python. The two major versions are Python 2 and Python 3. Choosing one over the other might be better depending on your project details. If there are no constraints, choose whichever one you prefer.

We recommend Python 3, as Python 2 reached its end of life in 2020. Download Python 2 only if you work with legacy scripts and older projects. Also, choose a stable release over the newest since the newest release may have bugs and issues.

Step 2: Download Python Executable Installer

Start by downloading the Python executable installer for Windows:

1. Open a web browser and navigate to the Downloads for Windows section of the official Python website.

2. Locate the desired Python version.

Python executable download page 64 and 32 bit

3. Click the link to download the file. Choose either the Windows 32-bit or 64-bit installer.

The download is approximately 25MB.

Step 3: Run Executable Installer

The steps below guide you through the installation process:

1. Run the downloaded Python Installer.

2. The installation window shows two checkboxes:

  • Admin privileges. The parameter controls whether to install Python for the current or all system users. This option allows you to change the installation folder for Python.
  • Add Python to PATH. The second option places the executable in the PATH variable after installation. You can also add Python to the PATH environment variable manually later.
Python installer admin privileges and path

For the most straightforward installation, we recommend ticking both checkboxes.

3. Select the Install Now option for the recommended installation (in that case, skip the next two steps).

To adjust the default installation options, choose Customize installation instead and proceed to the following step.

Python installer Install Now or Customize

The default installation installs Python to C:\Users\[user]\AppData\Local\Programs\Python\Python[version] for the current user. It includes IDLE (the default Python editor), the PIP package manager, and additional documentation. The installer also creates necessary shortcuts and file associations.

Customizing the installation allows changing these installation options and parameters.

4. Choose the optional installation features. Python works without these features, but adding them improves the program's usability.

Python installer optional features

Click Next to proceed to the Advanced Options screen.

5. The second part of customizing the installation includes advanced options.

Choose whether to install Python for all users. The option changes the install location to C:\Program Files\Python[version]. If selecting the location manually, a common choice is C:\Python[version] because it avoids spaces in the path, and all users can access it. Due to administrative rights, both paths may cause issues during package installation.

Other advanced options include creating shortcuts, file associations, and adding Python to PATH.

Python installer advanced options

After picking the appropriate options, click Install to start the installation.

6. Select whether to disable the path length limit. Choosing this option will allow Python to bypass the 260-character MAX_PATH limit.

Python installer setup successful

The option will not affect any other system settings, and disabling it resolves potential name-length issues. We recommend selecting the option and closing the setup.

Step 4: Add Python to Path (Optional)

If the Python installer does not include the Add Python to PATH checkbox or you have not selected that option, continue in this step. Otherwise, skip to the next step.

Adding the Python path to the PATH variable alleviates the need to use the full path to access the Python program in the command line. It instructs Windows to review all the folders added to the PATH environment variable and to look for the python.exe program in those folders.

To add Python to PATH, do the following:

1. In the Start menu, search for Environment Variables and press Enter.

Start Environment Variables search result

2. Click Environment Variables to open the overview screen.

System properties environment variables button.

3. Double-click Path on the list to edit it.

Environment Variables list Path variable

Alternatively, select the variable and click the Edit button.

4. Double-click the first empty field and paste the Python installation folder path.

Path Python new entry

Alternatively, click the New button instead and paste the path.

5. Click OK to save the changes. If the command prompt is open, restart it for the following step.

Step 5: Verify Python Was Installed on Windows

The first way to verify that Python was installed successfully is through the command line. Open the command prompt and run the following command:

python --version
python --version 3.12.0 CMD output

The output shows the installed Python version.

The second way is to use the GUI to verify the Python installation. Follow the steps below to run the Python interpreter or IDLE:

1. Navigate to the directory where Python was installed on the system.

2. Double-click python.exe (the Python interpreter) or IDLE.

3. The interpreter opens the command prompt and shows the following window:

Python 3.12.0 interpreter window

Running IDLE opens Python's built-in IDE:

Python 3.12.0 IDLE shell

In both cases, the installed Python version shows on the screen, and the editor is ready for use.

Step 6: Verify PIP Was Installed

To verify whether PIP was installed, enter the following command in the command prompt:

pip --version

If it was installed successfully, you should see the PIP version number, the executable path, and the Python version:

pip --version 23.2.1 CMD output

PIP has not been installed yet if you get the following output:

'pip' is not recognized as an internal or external command,
Operable program or batch file.

If an older version of Python is installed or the PIP installation option is disabled during installation, PIP will not be available. To install PIP, see our article How to Install PIP on Windows.

Step 7: Install virtualenv (Optional)

Python software packages install system-wide by default. Consequently, whenever a single project-specific package is changed, it changes for all your Python projects.

The virtualenv package enables making isolated local virtual environments for Python projects. Virtual environments help avoid package conflicts and enable choosing specific package versions per project.

To install virtualenv, run the following command in the command prompt:

pip install virtualenv
pip install virtualenv CMD output

Wait for the installation to complete. Once done, it is installed on the system and available for use.

Note: Learn more about Windows Package Manager's winget command by refering to our article winget upgrade - How to Update Packages.

Conclusion

In this tutorial, we described how to install Python on Windows. The process is similar for all Python versions.

If you already have Python installed and want to update to a newer version, check out our article on how to upgrade Python.

Was this article helpful?
YesNo
Milica Dancuk
Milica Dancuk is a technical writer at phoenixNAP who is passionate about programming. Her background in Electrical Engineering and Computing combined with her teaching experience give her the ability to easily explain complex technical concepts through her content.
Next you should read
How to Install Node.js and NPM on Windows
December 28, 2023

Node.js is a software application that runs JavaScript code. It's typically used for running scripts on the...
Read more
How to Check Python Version in Linux, Mac, & Windows
December 15, 2023

Python is a popular programming language with different versions organized by release date. Certain...
Read more
How to Install Latest Version Of Python 3 on CentOS 7
March 12, 2019

Python is a popular, stable, and well-performing programming language. CentOS 7 uses Python 2.7.5, but as...
Read more
How to Install Pip on Ubuntu 18.04
February 20, 2019

Pip is a software utility that downloads packages from PyPI the Python Package Index. Using PIP is like...
Read more