a shot of dev knowledge

RELATED TAGS

How to add Python to PATH variable in Windows

PATH variable

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; i​n the case that the required file is not found, it responds with an error message that states that​ the specified command was not recognized.

svg viewer

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:

  1. Right-clicking This PC and going to Properties.

  2. Clicking on the Advanced system settings in the menu on the left.

  3. Clicking on the Environment Variables button o​n the bottom right.

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

  5. 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: C:\Users\Educative\AppData\Local\Programs\Python\Python39

svg viewer

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring