‘python’ is not recognized as an internal or external command, operable program or batch file.
Tags: python, programming, codenewbie
Published: 2021-09-04 09:44:30

---
title: ‘python’ is not recognized as an internal or external command, operable program or batch file.
published: true
date: 2021-08-31 22:55:37 UTC
tags: #python #programming #codenewbie
canonical_url: https://itsmycode.com/python-is-not-recognized-as-an-internal-or-external-command-operable-program-or-batch-file/
---

ItsMyCode |

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](https://cdn.itsmycode.com/wp-content/uploads/2021/08/Environment-Variable.png)](https://cdn.itsmycode.com/wp-content/uploads/2021/08/Environment-Variable.png)

**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.](https://cdn.itsmycode.com/wp-content/uploads/2021/08/add-python-to-path-windows-10.png)](https://cdn.itsmycode.com/wp-content/uploads/2021/08/add-python-to-path-windows-10.png)

**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](https://cdn.itsmycode.com/wp-content/uploads/2021/08/Adding-Python-to-the-Windows-PATH-Environment-Variable.png)](https://cdn.itsmycode.com/wp-content/uploads/2021/08/Adding-Python-to-the-Windows-PATH-Environment-Variable.png)

The post [‘python’ is not recognized as an internal or external command, operable program or batch file.](https://itsmycode.com/python-is-not-recognized-as-an-internal-or-external-command-operable-program-or-batch-file/) appeared first on [ItsMyCode](https://itsmycode.com).