Keyboard Typing Coding

One of the great things about having Python installed on your Windows machine, is that you can access it from anywhere. Simply pull up a command prompt and you can start entering commands, installing new modules via pip, and feeling like a badass hacker!

In order for this to work though, you need to know how to add Python to PATH. PATH is an environment variable. This is what tells the command line which folders it needs to look in when searching for the file. If Python isn’t added to PATH, then you would need to point CMD directly to the Python.exe and then run the executable file:

C:\PythonX\python.exe

But once you know how to add Python to PATH, you can simply type “py” and start running! Likewise, with Python added to PATH, you’ll be able to run Python files as simply as:

C:\py PythonApplication.py

How to add Python to PATH

Before you read any further, it’s first worth checking whether Python is already available.

An easy way to do this is to simply type “py” or “python” at the command prompt. If Python is available, you’ll see the version number that’s installed on your machine and you’ll then be able to start using statements like “print.”

Good news, you can skip the next part of this post!

If you see:

'python' is not recognized as an internal or external command, operable program or batch file.

Then we have work to do!

Also read: How to print in Python

So how do you add Python to your path? The easiest option is to handle this while installing the Python interpreter. As you install Python, simply be sure to tick the box that says “Add Python to PATH.”

This can be found at the bottom of the image and it may be unticked by default!

How to add Python manually

If you already have Python installed, then installing a fresh version might not be an option. One option would be to uninstall and reinstall Python, or to simply update your current version.

Another option is to update your version of Python in order to go through the process again.

Also read: How to run a Python script in the terminal

Alternatively, you might learn how to add Python to PATH manually. Do this by right-clicking on “This PC” in explorer. Then click “Advanced system settings.”

How to add Python to PATH

Credit: Adam Sinicki/ Android Authority

Now, under the tab that says “Advanced,” choose “Environment Variables…”

Click “New” and then enter “Path” where it says “Variable Name.”

Where it says “Variable Value,” you’re going to copy and paste the full path of your Python application.

And there you go: that’s how you add Python to PATH!

Also read: How to run a Python script in the terminal or CMD


Now that Python is up and running on your machine, you may want to take your learning to the next level! We’ve compiled a list of the very best online course for learning Python, including a number of huge deals. Check that out here:

Comments
Read comments