Setting path for Python

Windows allows environment variables to be configured permanently at both the User level and the System level, or temporarily in a command prompt. In order to run Python conveniently from a command prompt , you might consider changing some default environment variables in Windows. To temporarily set environment variables , open Command Prompt and use the set command: C:\>set PATH=C:\Program Files\Python 3.6;%PATH%

How to set python path in windows

To permanently modify the default environment variables : My Computer > Properties > Advanced System Settings > Environment Variables > Edit
  1. Right-click 'My Computer'.
  2. Select 'Properties' at the bottom of the Context Menu.
  3. Select 'Advanced system settings'
  4. Click 'Environment Variables...' in the Advanced Tab
  5. Under 'System Variables': Click Edit

Add python's path to the end of the list (the paths are separated by semicolons(;))

How to add to the pythonpath in windows

Using Python from a command windows?

Open a command prompt window (press Windows+R, type in cmd, and hit enter).

Just type "python" on the command line and see if you get an error or not. If you see a response from a Python interpreter it will include a version number in its initial display.
Python Download and install
Success, now you can start programming on Python .

Python is not recognized..

python path windows 10
If you still get the Python is not recognized as an internal or external command, operable program or batch file error, there is something wrong with your Path variable settings . Moreover, you will have to reopen all command prompt windows in order for changes to the Path variable take effect.

Setting Python Path in Unix or Linux

To add the Python directory to the path for a particular session in Unix/Linux :
csh shell: type setenv PATH "$PATH:/usr/local/bin/python" and press Enter.
bash shell (Linux): type export ATH="$PATH:/usr/local/bin/python" and press Enter.
sh or ksh shell: type PATH="$PATH:/usr/local/bin/python" and press Enter.
  1. /usr/local/bin/python is the default path of the Python directory.


PYTHONPATH is an environment variable which you can set to add additional directories that Python should add to the sys.path directory list. For most installations, you should not set these variables since they are not needed for Python to execute normal programs because Python knows where to find its standard library. PYTHONPATH is used to assist in import module lookup. So when you import modules in your Python scripts, PYTHONPATH is also looked into to check which directories might contain the imported module .

How to add to the PYTHONPATH in Windows?

My Computer > Properties > Advanced System Settings > Environment Variables >
  1. Click the "New" button in the top half of the dialog, to make a new user variable.

  2. Give the variable name as PYTHONPATH and the value is the path to the code directory.

python path in ubundu
  1. Click OK and OK again to save this variable.
In order to confirm PYTHONPATH , open a Command Prompt and type:
Now you can confirm the environment variable is correctly set.
  1. Don't confuse it with Python PATH environment variable. That is used to assist OS (Operating system) in invoking an executable from anywhere. Which means if you just type Python on your Command Window, system will look into PATH to see which directories might contain an executable named python.