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 essence, by adding Python to my PATH, I’m telling Windows “hey, look here for Python.” In this tutorial, I will be adding Python to my PATH environment variable. Windows 10 is used in this tutorial, but this also works in Windows 7, 8, and 11.
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:
Instead, I simply type this into my command line:
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!
How to Add to PATH Environment Variable
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.
- Once in the System and Security tab, click “System.” This will open a new window.
- In this window, click “Advanced system settings.” This will be on the right or the left-hand side of the window depending on your system. This will open a window called “System Properties.”
- In the System, Properties window, click the “Environment Variables…” button.
- In the User variables section, click “new.” This will open the “New user variable” screen. This is where things get a bit more difficult. Before moving further, you’ll want to know the location, on your computer, where the application you’re looking to add to your path is installed. In my case, I’m adding Python 3 to the path. For me, Python 3 is located at C:\Python30. What you will be adding in this section will vary depending on what you’re adding to your Path.
- In the section titled Variable name, you can put whatever you want, but try to be descriptive. I’m going to name mine “python3path”.
- In the Variable value section, put the location of the application you want to be added 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.
Need help? Follow along in this video, “change path environment variable windows 10“!
Test 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, do check the video guide above where I walk you through the process, step-by-step, of adding to my PATH.
I’m curious about what you’re adding to your PATH. Let me know in the comments below!