Edit or Add to PATH Environment Variable in Windows 10
Why Add to PATH?
PATH is an environment variable and by adding something to PATH, you are telling your system where to look when it's looking for a particular file. In this tutorial, I will be adding Python to my path. In essence, by adding Python to my PATH, I'm telling Windows, "hey, look here for Python."By doing this, I don't have to write a book in my command line every time I want to run a Python file, like this:
C:/Python3/Python my_python_code.py
Instead, I simply type this into my command line:
python my_python_code.py
It seems like a minor difference, but remember that you'll otherwise have to remember the path to your Python installation! In this tutorial, I will be using Windows 10 to get the job done. Let's get started!
Note: In this guide, we will be modifying system variables.This can affect how your system operates. Before making changes, it's always a good practice to back up your current PATH. You can do this by copying what's in your PATH field and pasting it somewhere safe. That way, if you've made a mistake, you have a backup.
How to Add to Your PATH environment variable in Windows 10
Let's get started adding Python 3 to the PATH. You can follow along with whatever you're adding to your system's PATH.On the lower left-hand side of your screen, where it says "Type here to search", type "control panel" and navigate to your Control Panel.
The window that pops up is the Control Panel. Click "System and Security" at the top left-hand side of this window. If you don't see "System and Security", on the top right, click the dropdown box next to the words "View by" and switch it to Category.
In the System Properties window, click the "Environment Variables..." button.
If you already have a Path variable, you'll just add to the current one:
- In the user variables section, select "Path." Then right below it, select "Edit." Copy what's in the "variable value" field and paste it somewhere safe (such as in an email to yourself.)
- In the section titled "variable name", you can name your variable whatever you want but try to be descriptive. I'm going to name mine "python3path".
- At the end of the list of variable values, add a semicolon, then skip to the "Adding Your Variable" section below.
Adding Your Variable
This is where things get a bit more difficult. Before moving further, you'll want to know the location of the application you're looking to add to your path.In my case, I'm adding Python 3 to the path. For me, Python 3 is located at
C:\Python30
In the "Variable value" section, put the location of the application you want to add to your path. I will put:
C:\Python30
Then press "ok" on this screen. Don't forget to hit "okay" on the Environmental Variables screen as well.
Troubleshooting
Sometimes things might not work as expected after modifying the PATH. Here are some common mistakes people make:- Forgetting to separate paths with a semicolon.
- Mistyping the directory path.
- Not restarting command prompt or the system after making changes.
Try It Out!
Now that you've added an application to your path, it's time to test it out. In my case, I have created a Python script. The Python logo shows up on my script, so I know it's connected to Python via the PATH variable I set. However, this is just one sign that it's working. The best way to try it out is to open the command prompt and run it from there.If you have any questions, feel free to comment below. If you're having trouble with a particular section of this tutorial, check out the video guide above where I walk viewers through the process, step-by-step, showing how I add a variable to my PATH.

.png)
.png)

.png)

.png)
.png)
.png)
Comments
Post a Comment