Python is the most widely used high-level web application development language. With the simple syntax, it was designed to improve the readability of the programs. It runs on the Interpreter system which helps to execute the code as soon as it is written. If you are writing a code using Python programming then you may have come across the error “‘python’ is not recognized as an internal or external command operable program or batch file”.
This article will help you to learn about the exact cause of this error and how to get rid of this python error.
Reason for “’python’ is not recognized as an internal or external command”
As mentioned in the error message, your computer is not able to find and execute the required python executable. That is why it’s throwing the error ‘python’ is not recognized as an internal or external command.
There are two major reasons which may result in this error message i.e. either Python is not installed on your computer or the system environment variable is not set.
Follow the below steps to fix the error while executing your first Python program.
Step 1: Install Python on your computer
Check whether you have installed Python or not. If you have not installed Python on your system and trying to use the python command then it is obvious to get the error message as this functionality is not available on your computer.
If you have not installed python then install the latest version of python on your environment.
Read: Steps to install Python and run your first program
If you have already installed Python on your computer and still getting the error, follow the next step.
Step 2: Set PATH variable
Note: Here we are assuming you have installed python on your environment.
If you have installed python and still you are getting the error message then check for the system PATH variable. Either you have not entered the python executable path in the PATH system variable or the entered path is incorrect.
Here are the steps to set the correct python executable path in the environment variable.
- Go to Control Panel –> System and Security –> System
- Click on Advanced system settings. It opens the ‘System Properties’ dialog box.
- In the ‘System Properties’ dialog box, select the Advanced tab and click on the ‘Environment variables…‘ button as shown below to open the environment variable window.
- Under the ‘System variable’ section, select the PATH variable and click on Edit.
Note: Make sure to set the value in the ‘System variable’ section and not in the user variable.
- Add Python executable path in the variable list as shown below and click OK.
- Close all windows and open a new command prompt and compile your program. Now it will compile your program without any error.
Note: After setting the environment variable, make sure to use a new command prompt to execute the python command again. If you tried to run the python command on the same command prompt then you will again get “python is not recognized as an internal or external command” error message as the new path will not be reflected in the same cmd session.
There are three following takeaways from this article to resolve “‘python’ is not recognized as an internal or external command, operable program or batch file” error.
- Install python compiler.
- Set system Path variable value.
- Run command on a new command prompt.
Easy, isn’t it? Do let us know whether you are able to fix this error with the above steps in the comment section. Cheers!