22
‘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.
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.
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.
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.
The post ‘python’ is not recognized as an internal or external command, operable program or batch file. appeared first on ItsMyCode.
22