How to add Python to the Windows PATH variable

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 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 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 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 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 5

4.7 ★ | 3 Vote

May be interested

  • Variable in C programmingVariable in C programming
    a variable in c is nothing but a name given to storage memory so that the program can be manipulated. each variable in c has a defined type, to determine the size and layout for that variable memory. the range of values ​​that can be stored in memory, setting of expressions can be applied to variables.
  • More than 100 Python exercises have solutions (sample code)More than 100 Python exercises have solutions (sample code)
    more than 100 python code examples are shared by guy zhiwehu on github, however, the solution of this series is written on the old python version. following tipsmake.com will be vietnameseized and edited to suit python 3.x to help you learn and practice python.
  • How to Set the Path in JavaHow to Set the Path in Java
    this wikihow teaches you how to set the path for your java installation on windows, macos, and linux. if you're using a windows pc or mac and have just installed java, there's typically no need to do this manually as the path is set during...
  • How to fix the long path of the directory path on WindowsHow to fix the long path of the directory path on Windows
    long path fixer will fix path errors too long when accessing, moving, copying. by default, windows api will only support 260 characters.
  • Bookmark 5 best Python programming learning websitesBookmark 5 best Python programming learning websites
    if you are a developer or you are studying and want to stick with this industry, learn python to add a highlight in your journey.
  • Global keywords in PythonGlobal keywords in Python
    what does the global key do and how do i use it in python? please follow us.
  • Did you know Windows 10 solved the path problem longer than 260 characters? Read the article belowDid you know Windows 10 solved the path problem longer than 260 characters?  Read the article below
    on windows 10 anniversary update, microsoft finally 'solved' the problem that developers have had a headache for a long time, which is the path length limited to 260 characters.
  • For in Python loopFor in Python loop
    in this article, we will learn more about for for loop in python as well as its variations, how to use for to repeat a string of elements in python such as list, string or other iterative objects.
  • Manage files and folders in PythonManage files and folders in Python
    python also provides a variety of methods to handle various directory-related operations. in this article, we will learn about managing files and directories in python, namely creating folders, renaming folders, listing folders and working with them.
  • Multiple choice quiz about Python - Part 3Multiple choice quiz about Python - Part 3
    today's topic quantrimang wants to challenge you is about file and exception handling in python. let's try the following 15 questions!