DEV Community

Lalit Kumar
Lalit Kumar

Posted on

How to add to the PYTHONPATH in Windows, so it finds my modules/packages?

What is PYTHONPATH?

PYTHONPATH is an environment variable in python which adds additional libraries in the directory that python should add in the directory list. To execute you donโ€™t need these variables because python knows where to find standard libraries. PYTHONPATH is used for assistance in python modules to import the python scripts. PYTHONPATH also check which libraries accommodate imported modules.


title: "originally posted here ๐Ÿ‘‡"

canonical_url: https://kodlogs.com/blog/66/how-to-add-to-the-pythonpath-windows-finds-modules-packages

Procedure to add PYTHONPATH in windows:

  • Go to MY Computer icon then click on Properties > Advance system settings> Environment Variables.
  • Click on the โ€œnewโ€ button in the upper half of the dialog, to create a new variable for the user.
  • The variable name is given as PYTHONPATH and the value represents the path to the code directory.
  • Click Ok
  • Click OK again to save the variables. ###Procedure for confirmation of PYTHONPATH:
  • Open the command prompt by applying the given procedure
  • Press window+R.
  • A dialog box will appear. Enter โ€œcmdโ€.
  • Press Enter
  • Command Prompt will open and type the following command echo %PYTHONPATH% Now you can see that the environment variable is set correctly

Note:
Never confuse this with Python PATH environment variable which is used in an operating system for the assistance to invoke form anywhere. This means if you are just going to type Python the command window, then the system will look the PATH to just find the executable with the name python.

Top comments (0)