The PATH variable is a list of directories where each directory contains the executable file for a command.
When a command is entered into the Windows command prompt, the prompt searches in the PATH variable for an executable file with the same name as the command; in the case that the required file is not found, it responds with an error message that states that the specified command was not recognized.
One way to overcome this error is to write the complete directory of the executable file instead of only entering the command name. However, this is not a very user-friendly approach.
Another possible, and easier, way to avoid this error is to add the executable file’s directory to the PATH variable. Oftentimes, this needs to be done when installing Python.
The complete path of
python.exe can be added by:
Right-clicking This PC and going to Properties.
Clicking on the Advanced system settings in the menu on the left.
Clicking on the Environment Variables button on the bottom right.
In the System variables section, selecting the Path variable and clicking on Edit. The next screen will show all the directories that are currently a part of the PATH variable.
Clicking on New and entering Python’s install directory.
Python can now be used directly from the command prompt without having to write its location. Try executing the command
python --version; it will output the version of Python installed on your system.
Usually you can find the python installed binary in this path location:
View all Courses