Python Python is not recognized as an internal or external command, operable program or batch file

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”.

Python 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.

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.
    Python Python is not recognized as an internal or external command, operable program or batch file
  • 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.
    Python Python is not recognized as an internal or external command, operable program or batch file
  • 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.

Final words:

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!

How do you fix Python is not recognized as an internal or external command operable program or batch file?

Specify the full location to python.exe One way to fix the error would be to launch Python from the Command Prompt by passing in the full path to the executable file each time you wanted to run Python. In other words, instead of typing Python you would type something like C:\Users\me\path\to\python.exe .

How do I get Python to work in CMD?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!

Is not recognized as an internal or external command operable program or batch file?

You can resolve this issue in three ways: First, use the full path of the executable file to launch the program. Second, add the program path to Windows environment variables. Finally, move the files to the System32 folder.

How do I fix Python not recognized by PIP?

You can fix this by changing the Python install to include pip, and here's how:.
Press the Windows key + R to open Run..
Type appwiz. ... .
In Program and Features, right-click Python and click Change..
Select Modify..
In Optional Features, check the pip box and hit Next..
To apply the changes, click Install..