How to add Python to the Windows PATH variable

To help you through the hassle of adding Python to your Windows PATH after installation, look at the options and a few related steps.

Running Python from Terminal is usually unavoidable. However, if you have just installed Python on Windows 10 for the first time, then running it through the Windows Terminal is only possible if it is added to the Windows PATH environment variable.

How to manually add Python to the Windows PATH

First of all, if you don't have Python installed on your machine yet, visit the python.org website to download and install the preferred version.

Once Python is successfully installed on your PC, check if it has been added to the Windows PATH. Open Terminal and type python, then press Enter key. Command may return an error '' python 'is not recognized as an internal or external command, operable program or batch file'. ('python' is not recognized as an internal or external command, operable program or batch file), indicates that Python has not been added to the PATH variable on the machine.

To execute Python programs from the command line, follow the steps below.

Find the path to install Python on PC

To add Python to the Windows PATH, you need to get its installation path. To do that, open Windows search bar and type python.exe (don't press Enter key). Then right-click on the Python.exe that appears in the results menu and select the option Open file location.

In the Explorer window that opens, click the long folder bar to the left of the search bar. Highlight and copy the entire path text to the clipboard with Ctrl + C. Then continue to the next steps below.

How to add Python to the Windows PATH variable Picture 1How to add Python to the Windows PATH variable Picture 1

Add Python to PATH in User variables

To add Python to the PATH under User variables, right-click This PC and choose Properties. Once in the Properties menu, click the Advanced system settings option. In the next window, select the Advanced tab and select Environment Variables.

How to add Python to the Windows PATH variable Picture 2How to add Python to the Windows PATH variable Picture 2

The Environment Variables menu has two separate parts: The top section is called User variables and the bottom section is called System variables. However, the article will only focus on User variables in this case.

In the User variables menu, look for a variable called Path. Then paste the path you copied earlier into the Variable value option using Ctrl + V and click OK.

However, if you can't find the variable, you may need to create it. To do that, click New. Next, in the Variable name form, type Path and paste your Python path in the Variable value field.

How to add Python to the Windows PATH variable Picture 3How to add Python to the Windows PATH variable Picture 3

Go back to the Python installation path folder and double-click Scripts to open that folder. Next, copy its path from the path bar in the upper part of the window (next to the search bar), just like you did before for the Python installation path.

Once you've copied the Scripts path, go back to Environment Variables. Next, select Path variable and click Edit. Type a semicolon after the Python execution path and paste the Scripts path you just copied after it. Then click OK.

Add Python to PATH with System Variables option

You can also add Python to PATH System Variables. Though this is just an alternative and not necessary if you have already added it in Users variables.

To use the System Variables option, follow the steps above to copy its Python path and Scripts path. Then go back to Environment Variables. Next, inside the System Variables segment, locate a variable named Path. Click on that variable and choose Edit.

In the next window that appears, click New and paste the path you copied earlier into the opened space. Repeat the same process for the Scripts path as well. Next, click OK and close the Environment Variables window.

How to add Python to the Windows PATH variable Picture 4How to add Python to the Windows PATH variable Picture 4

Automatically add Python to Windows PATH

You can also add Python to Windows PATH automatically during installation.

While using this method doesn't work in all cases, you can still give it a try.

To do that, click on the setup file and check the box Add Python 3.7 to PATH. The version number will change when different Python versions are installed.

Checking that box will automatically add Python to the Windows PATH. That means you can start running Python commands through the command line right after installation.

Confirm that Python is added to Windows PATH

To see if Python has been added to the Windows PATH, open Terminal and type python --version, then press the Enter key. If the command returns the currently installed version of Python, it means you've successfully added it to the Windows PATH.

However, to check if you added the Scripts folder to your Windows PATH try running the pip installation package on Terminal, replacing "package" with your favorite library. If you have Python 2.7.9 or higher installed, the command will install the package with the corresponding name, indicating that you have also successfully added Python Scripts to the path.

How to add Python to the Windows PATH variable Picture 5How to add Python to the Windows PATH variable Picture 5

4.7 ★ | 3 Vote