How to add Python to PATH variable in Windows (2024)

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

What is a PATH variable?

A path variable contains a list of paths to executable programs in the machine. These programs can be placed anywhere in the machine, but when added to the PATH variable, they can be accessed from any directory in the system.

Whenever we enter a command into the terminal, the system looks up the PATH variable for the path where the program is placed, which refers to the command. If the path to the required file is not found, it responds with an error message stating that​ the specified command was not recognized.

How to add Python to PATH variable in Windows (1)

How to add Python to PATH variable in Windows (2)

Steps to add Python to PATH

Below are the steps we must take to add python to our PATH variable.

  1. First, we must find the directory where we installed Python. A typical installation would have the following path, C:\Users\MyUserName\AppData\Local\Programs\Python\Python310

  2. Now, we will need to add this to the PATH variable, we right click on "This PC" and go to "Properties".

  3. Then, we click on the "Advanced system settings" in the menu on the left.going

  4. In the bottom right, we can see a button labeled "Environment Variables". We will click on it to open another window to edit these variables.

  5. Now, we select the "Path variable" in the "System variables" section and click "Edit". The next screen will show all the directories currently part of the PATH variable.

  6. Another window opens up where we can see all the paths for the currently configured system variables. To add a new path for our Python program, we will click on the "New" button on the right side and paste the path in Step 1

  7. We have successfully added the path for our Python program to our system's environment variables. The best practice is to restart the system afterward for the change to occur.

  8. Now, we can verify if the PATH variable was configured correctly by opening up the terminal and entering the command python --version.

After all the following steps are completed, when we run the command on the command prompt, we should get a similar output to the one shown below

How to add Python to PATH variable in Windows (3)

RELATED TAGS

python

windows

path

variable

executable

Copyright ©2024 Educative, Inc. All rights reserved

How to add Python to PATH variable in Windows (2024)
Top Articles
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 5475

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.