Err: Python is not recognized as an internal or external command

The “Python is not recognized as an internal or external command” error is encountered in the command prompt of Windows.

This Python error occurs Python is not added to the system's PATH environment variable during installation. The PATH variable in windows tells the operating system where to find executable files, and if Python is not included in it, the system won't recognize Python commands.

To resolve this issue, we need to make sure that Python is correctly installed and added to the PATH environment variable. We can achieve this by installing Python again and checking the option to add Python to the system PATH during installation, Python can also be added to the PATH variable manually in our system settings. Once Python is properly configured in the PATH, the error should no longer occur, and we'll be able to execute Python commands and scripts from the command prompt or terminal.

Solution

To resolve this error, follow the steps below:

  1. Find a folder with the installed Python version as its name in X:\Program Files (where X is the drive where Windows is installed; e.g.,C:\Program Files\Python36). If such a folder does not exist, download and install the latest version of Python from here.

  2. Open this folder and copy its path.

  3. Right-click on "This PC", then go to "Properties => Advanced system settings => Environment variables".

  4. In the window that appears when a PATH variable exists, select it, ​and click "Edit"; otherwise, click "New".

  5. In the next dialogue box, click on "New" and paste the previously copied path of the folder; then, click "OK".

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved