All three methods are tested and it is working in all versions of windows OS.
- Hold down windows key and press pause key.
- Click Advanced System Settings.
- Click Environment Variables.
Setting path at Windows
To add the Python directory to the path for a particular session in Windows −
In command prompt − type path %path%;C:\Python and press Enter.
Note − C:\Python is the path of the Python directory
Python Environment Variables
Here are important environment variables, which can be recognized by Python −
|S.No.||System Variable & Description|
It has a role similar to PATH. This variable tells the Python interpreter where to locate the module files imported into a program. It should include the Python source library directory and the directories containing Python source code. PYTHONPATH is sometimes preset by the Python installer.
It contains the path of an initialization file containing Python source code. It is executed every time you start the interpreter. It is named as .pythonrc.py in Unix and it contains commands that load utilities or modify PYTHONPATH.
It is used in Windows to instruct Python to find the first case-insensitive match in an import statement. Set this variable to any value to activate it.
It is an alternative module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.
- [Right Click]Computer > Properties >Advanced System Settings > Environment Variables
- Click [New] under “System Variable”
- Variable Name: PY_HOME, Variable Value:C:\path\to\python\version
- Click [OK]
- Locate the “Path” System variable and click [Edit]
- Add the following to the existing variable:
- Click [OK] to close all of the windows.
As a final sanity check open a command prompt and enter python. You should see
>python "type version"
If you need to switch between versions, you only need to modify the PY_HOME variable to point to the proper directory. This is bit easier to manage if you need multiple python versions installed.