'python' is not recognized as an internal or external command

'python' is not recognized as an internal or external command, operable program or batch file. When this error happens while typing python in the Windows terminal (or command prompt), then you first need to ensure that Python is installed. For this you can press or click the Start button (the one with the Windows logo) and then type "python" (without quotes). On Windows 8, look for the search button at the top-right corner of the screen.

/images/python-is-not-recognized/windows-start-python.png

If you don't see something similar to the previous image, then you don't have Python installed. Download the latest version from https://python.org and when running the installer make sure to check the "Add Python 3.x to PATH" option. But if you do have Python installed, and nevertheless the python command is not working in the terminal, then keep reading.

The first step is to locate the folder where Python is installed. Just right-click the Python application you found in the previous step and press "Open file location", as shown in the image:

/images/python-is-not-recognized/windows-start-python-open-file-location.png

Windows will open the file explorer in the folder where the Python shortcuts lie:

/images/python-is-not-recognized/python-shortcuts.png

Again, right-click the "Python 3.x (64-bit)" (or similar, the "64-bit" might not appear) shortcut and press "Open file location":

/images/python-is-not-recognized/python-shortcut-open-file-location.png

You will be redirected to the Python installation folder:

/images/python-is-not-recognized/python-installation-path.png

Now we need to copy the path of that folder. Click the explorer's address bar (as indicated by the red arrow in the previous image) so the folder path is revealed as plain text.

/images/python-is-not-recognized/python-installation-path-revealed.png

Copy the folder path since we will use it afterwards.

Next, press or click again the Start button, but this time type in "variab" (without quotes).

/images/python-is-not-recognized/windows-search-variables.png

Click on "Edit environment variables for your account". The following window will be shown:

/images/python-is-not-recognized/windows-user-variables.png

In the first list, look for the "Path" variable, select it, and then press the Edit... button, as stated in the image. The following popup will appear:

/images/python-is-not-recognized/windows-edit-environment-variable.png

Just ignore the items that are already there. You will probably have just a few items, or even an empty list. Press the New button, which will let you type in a new item. Paste the Python installation path (for example, C:\Python39) you have copied in the previous step. Then press New again and add the \Scripts folder to the Python installation path, like this:

/images/python-is-not-recognized/windows-edit-environment-variable-python.png

Click OK in both dialog boxes. Open a new terminal or command prompt, and write python. Now you will see:

/images/python-is-not-recognized/python-interactive-console.png

Voilรก!