How To: Add Path to Python in Windows



Updated December 2024: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
  1. Download and install the repair tool here.
  2. Let it scan your computer.
  3. The tool will then repair your computer.

If you installed Python on Windows using the default installation options, the path to the Python executable file was not added to the Windows path variable. The Path variable lists the directories that are searched for for executables when you type a command at the command prompt. If you add the path to the Python executable file, you can access the python.exe file by typing the python keyword (you do not have to specify the full path of the program).

Whenever you need Python to import a module, Python looks at all the files in its path list to find it. Information on the path comes from three sources:

  • Environment variables : Python environment variables, such as PYTHONPATH, tell Python where to find the modules on the disk.
  • Current directory : You can change the current Python directory so that it can find all the modules used by your application.
  • Default directories: Even if you do not define environment variables and the current directory does not provide usable modules, Python can still find its own libraries in all the default directories that are included in its own path information.

It is useful to know the information of the current path, because the absence of a path can cause your application to fail. The following steps show how to get information about the path.

How To: Add Path to Python in Windows

Think about what happens if we type the python command at the command prompt and the path to this executable is not added to the Path variable :

December 2024 Update:

You can now prevent PC problems by using this tool, such as protecting you against file loss and malware. Additionally, it is a great way to optimize your computer for maximum performance. The program fixes common errors that might occur on Windows systems with ease - no need for hours of troubleshooting when you have the perfect solution at your fingertips:

  • Step 1 : Download PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista – Microsoft Gold Certified).
  • Step 2 : Click “Start Scan” to find Windows registry issues that could be causing PC problems.
  • Step 3 : Click “Repair All” to fix all issues.

Download Now

C:\>python
Python’ is not recognized as an internal or external command,
functional program or batch file.

As you can see on the output above, the command was not found. To run python.exe, you must specify the full path of the executable file :

C:\>C:\Python34\python –version
Python 3.4.3

For Windows 10/8/7:

  1. Open System Properties (right-click on Computer in the Start menu, or use the Win+Pause shortcut).
  2. On the sidebar, click Advanced System Settings.
  3. Click on Environment Variables………….
  4. In the System Variables pane, select Path.
  5. Click on Modify

Add the Python path at the end of the list (the paths are separated by semicolons). For example:

C:\Windows;C:\Windows\System32;C:\Python27

For Windows XP:

  1. Open the system properties (enter them in the Start menu or use the Win+Pause key combination).
  2. Go to the Advanced tab
  3. Click on Environment Variables………….
  4. Select PATH in the System variables field.
  5. Click on Modify

Add the Python path at the end of the list (the paths are separated by semicolons). For example:

C:\Windows;C:\Windows\System32;C:\Python27

Test in a new terminal window or when using a terminal integrated in a text editor, close and restart your editor or the changes are not applied.

CONCLUSION

Python is a programming language that was first published in 1991. It has an application that can be used on multiple operating systems, and developers can write and develop new code on it. Python is one of the most widely used programming languages because it offers many possibilities and extensive support for the developer.

Each time the user enters the words “python” in the prompt, he returns an error and the entire path must be specified for it to work correctly. Indeed, the prompt must find the file “python.exe” to load the output, and it can only do so if the full path has been specified. This article shows how to continuously add a path to Python to solve this problem. Then, you can run “python.exe” without having to specify the full path.

https://stackoverflow.com/questions/12257747/permanently-adding-a-file-path-to-sys-path-in-python



Expert Tip: This repair tool scans the repositories and replaces corrupt or missing files if none of these methods have worked. It works well in most cases where the problem is due to system corruption. This tool will also optimize your system to maximize performance. It can be downloaded by Clicking Here

Scroll to Top