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

The ‘python’ is not recognized as an internal or external command, operable program or batch file. error is encountered in the command prompt of Windows after you install Python on the windows machine. The error is raised when Python executable file path is not added in an environment variable. 

Since the problem is at execution, windows will not let you execute any Python code, even on the command prompt, and throws an error Python is not recognized as an internal or external command.

So what does this error mean, and why does it appear in the first place? Well, whenever you run any python code on your computer, the installed Python library is the one that will compile and execute the code. If you run the code in the same path where the Python executable is located, your code executes properly.

If you run it in any other path, then windows won’t know how to execute your code, and this can be resolved by adding Python executable in an environment variable.

Adding Python to the Windows PATH Environment Variable

Let’s go step by step process to add python to path windows 10 environment variable.

Step 1: Assuming that you have already installed Python on your windows machine, as a first step, locate the folder path where you have installed the Python. Usually, it will be in the OS directory “C:\Program Files\Python3.x” or inside “C:\Users\{user_name}\AppData\Local\Programs\Python\Python3.x” it may vary if you have installed OS in a different drive or Python is installed in a different directory. Alternatively, take the help of windows search in locating the file.

Step 2: Once you locate the file, right-click again and choose “Properties.” Copy the full “Location” path.

Step 3: Right-click This PC, then go to Properties => Advanced system settings => Environment variables.

Add Python To Path Windows 10
'python' is not recognized as an internal or external command, operable program or batch file. 4

Step 4: You’ll see your variables here. Select the PATH variable and click the “Edit” button. In the window that appears when a path variable exists, select it ​and click Edit; otherwise, click New.

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

Step 5: Finally, paste the path you copied earlier in Step 1. If your system has many paths linked by semicolons, append the path by prefacing it with a semicolon. Click Ok to save.

Once you have completed all the steps, try running the Python program from your command prompt. You can run the ‘py’ or ‘python’ command, and you should not see any error hereafter. Remember to close all the command prompt windows and reopening them again after completing the above steps. 

If you are downloading and installing the latest version of Python 3.6+, then during the installation itself, the installer will prompt you to automatically add the Python to system PATH.  

Adding Python To The Windows Path Environment Variable
'python' is not recognized as an internal or external command, operable program or batch file. 6

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like