Adding Python path to Windows 10 or 11 PATH environment variable

Reading Time: 7 minutes

Python remains one of the most popular programming languages thanks to its versatility and user-friendly syntax. Python code and assets can be seamlessly used across major desktop operating systems, such as macOS, Linux, and Windows.

If you are an aspiring Python developer using a Windows machine, it is essential to ensure that Python is readily accessible from any location within your system. Achieving this requires the addition of the Windows 10 or 11 PATH environment variable, allowing your system to recognize and execute Python commands regardless of the current directory. Let's walk through adding the Python path to the Windows 10 PATH or Windows 11 PATH environment variable.

You will be provided instructions intended for all users of all experience levels, including beginners stepping into the world of Python for the first time. Before delving into the procedure, we will review some fundamental aspects of the PATH variable in the context of the most recent Windows-based operating systems.

Key points found in this article

Once you have read the content within this webpage, the following takeaways are the most prominent:

  • Understanding PATH as an essential OS environment variable that is used to specify the location of Python libraries and its setup requirements on Windows.
  • Knowing about the executable file order in PATH for the Windows OS and its importance.
  • Adding Python to Windows PATH automatically with the installer.
  • Manually adding Python to Windows PATH, when necessary.
  • Changing Windows system properties to include Python path details, if needed.
  • Verifying PATH was added correctly in Windows via a launch of Python without any errors.

What is PATH?

In the context of Python, PATH refers to an environment variable used to define the system location of all the necessary Python libraries, allowing the system to execute Python commands. PATH typically consists of several directories the operating system searches when executing Python commands on a computer.

Whenever a user enters a command in Terminal (for macOS and Linux) or PowerShell (for Windows), the operating system scans through the directories listed in the PATH variable to determine which one is associated with the command the user has input.

The importance of order in PATH

Order in PATH is crucial, as it determines which executable file is accessed first when a command is entered. As mentioned earlier, when you run a command in Terminal or PowerShell, your OS will search for the corresponding executable file in the directories listed in the PATH environment variable. The corresponding executable file that is found first will be executed.

Your system will display an error message if no corresponding executable file is found. The order of PATH is even more significant when a user is running different versions of the same program, or when you want to prioritize specific executables over others. In this case, the user has to rearrange the directories in the PATH variable to tell the OS which version of a program is executed first when they run a certain command.

Now that you know what PATH means, here are two different methods of adding a Python path to your Windows 10 PATH.

Method #1. Add Python to Windows PATH from the newest installer

The latest Python installer for Windows can set the system environment variable path automatically if selected during the installation process. This is, in fact, the easiest method for adding Python to the Windows PATH environment variable. When installing Python, you will see the option to add Python to the PATH automatically. All you need to do is select the Add Python 3.5 to PATH checkbox, as shown in the image below in an unchecked state:

Adding Python path to Windows 10 or 11 PATH environment variable — add Python to Windows PATH from the newest installer.



You can obtain the newest Python installer by visiting the official Python website and navigating to the Downloads section. While on this page, make sure you download the latest version available.

Once you download the installer, run it and remember to select the above option to ensure your Python path is added to Windows 10 PATH. This same process also works if you are using Windows 11.

Method #2. Add Python to Windows PATH manually

Another alternative is to add Python to Windows PATH manually. It is only recommended to use this method if the first one doesn’t get the job done. This method involves modifying the path of an existing Python installation. It could also be used to verify if the Python path setting is correct or current. To add Python manually to the Windows 10 PATH, follow the steps in the sections Step 2.1 through Step 2.7 listed in the following sections.

Step 2.1. Verify Python path is added to the Windows 10 or 11 PATH system environment variable

First, you must verify that your Python path is added to Windows 10 PATH before doing anything. To do this, you must use the command prompt or PowerShell. Open the command prompt as an administrator by clicking Start, navigating to Windows System, and selecting Command Prompt. You should right-click it and choose the Run as Administrator option. You can use the same process to open PowerShell as an Administrator:

Adding Python path to Windows 10 or 11 PATH environment variable — verify Python path is added.


Step 2.2. Launch Python via the Administrator Command Prompt or PowerShell

While in the command prompt or PowerShell, type the word python and press the Enter key. If your Python path was correctly added, Python should launch immediately. However, you will most likely receive an error if Python’s path has not set in the system environment variables. To fix this issue, proceed to the next step.

If the system variable path is correctly set and you used the command prompt, you should receive output similar to what is shown below:

Adding Python path to Windows 10 or 11 PATH environment variable — launch Python (command prompt).



If you are using PowerShell, below is what your output will look like:

Adding Python path to Windows 10 or 11 PATH environment variable — launch Python (PowerShell).



If an error is seen indicating that the Python command is unknown, but we have confirmed that Python is installed and can be launched from within its directory, we will need to add the Python path to the system environment variables. Continue to the next step to accomplish this setup.

Step 2.3. Make necessary changes via the System Properties dialog box

You will start by making some changes via the System Properties user interface . To open the System Properties dialog box, first press the Win+R keys to open the Run dialog. Input the text string sysdm.cpl, and press the Enter key. When the System Properties dialog box opens, click the Advanced tab found along the top of the System Properties dialog box. Finally, click the Environment Variables button at the bottom of box:

Adding Python path to Windows 10 or 11 PATH environment variable — change system properties.


Step 2.4. Locate user and system variables in the Environment Variables dialog box

If the above steps were done correctly, you should now see the User Variables for Administrator and System Variables sections within the Environment Variables dialog box. Proceed to the next step:

Adding Python path to Windows 10 or 11 PATH environment variable — locate user and system variables.


Step 2.5. Create a new user variable from the User Variables for Administrators section

You will now have to create a user variable. To do this, click the New button under the User Variables for Administrators section:

Adding Python path to Windows 10 or 11 PATH environment variable — create a user variable.



A new window will open, and you should input the following information:

  • Variable Name:Python
  • Variable Value:C:\Users\***username***\AppData\Local\Programs\Python\Python38

Be sure to modify the actual Variable Value entry used to match your actual Python installation path as it may not be the same as the one above:

Adding Python path to Windows 10 or 11 PATH environment variable — be sure to modify the actual Variable Value entry used to match your actual Python installation path.


Step 2.6. Edit the Path entry in the System Variables section

Locate the Path entry in the System Variable section, highlight it, and then use the Edit button to open the dialog box shown in the next section:

Adding Python path to Windows 10 or 11 PATH environment variable — edit path entry.


A new dialog box will open, and you must create a new entry that matches the Path variable from the previous step. However, you will need to addScripts\ to the end of the entry. So, your input in this section should look like this:

C:\Usersyourusername\AppData\Local\Programs\Python\Python38\Scripts\


Adding Python path to Windows 10 or 11 PATH environment variable — a new dialog box will open, and you must create a new entry that matches the Path variable from the previous step. However, you will need to add Scripts\ to the end of the entry.


Step 2.7. Verify PATH was added correctly in Windows to launch Python without any errors

After inputting the entry in the previous step, click the OK button in all three open windows to save the changes made.

Finally, you now have to verify that the PATH was added correctly by opening the command prompt as administrator and running the python command. If it was added correctly, Python should launch without any errors:

Adding Python path to Windows 10 or 11 PATH environment variable — verify PATH was added correctly in Windows to launch Python without any errors.



You will receive a response similar to what is shown above. By following these quick steps, you’ll be able to access Python from any command prompt.

Note:
The installation of Python software falls under our Beyond Scope Support. This means it is not covered under our managed support, but we will do what we reasonably can to assist. Find out more in our article What Is Beyond Scope Support?


Wrapping up

Python is a powerful programming language that is scalable and uses code that is readable and clear for all types of projects. It is one of the most popular programming languages existing today. As such, Python is also available across a number of operating systems, making it a popular choice for developers. If you are using Python on your Windows operating system, you may need to adjust your system environment variables to simplify utilizing Python on your server. This article covered how to add the Python path to Windows 10, which will work for Windows 11 as well.

As you have seen in this guide, adding the Python path to the Windows 10 PATH variable is crucial for guaranteeing Python runs correctly on your Windows machine. The easiest method is to use the latest Python installer, which adds this path automatically. However, you can also add it manually using the steps shared in Method #2 above if not added automatically during installation.

Our talented support team is full of experienced System Administrators and technicians who have intimate knowledge of multiple web hosting technologies, especially those discussed in this article. We are always available to assist 24 hours a day and 365 days a year — 366 day a year on leap years. If you are a Fully Managed VPS Server,Cloud Dedicated Hosting, VMWare Private Cloud Hosting, Private Parent Server, or Dedicated Server customer and you are uncomfortable with performing any of the steps outlined, we can be would be happy to assist you with this process.

Avatar for Chika Ibeneme

About the Author: Chika Ibeneme

Chika Ibeneme is a Community Support Agent at The Events Calendar. He received his BA in Computer Science in 2017 from Northern Caribbean University and has over 5 years of technical experience assisting customers and clients. You can find him working on various WordPress and Shopify projects.

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article