How to edit PYTHONPATH on Windows

You are here because you’re using:

  • Windows OS version 10+
  • Python version 3.3+
  • Anaconda3

And you’d wish to edit your PYTHONPATH permanently.


  • Go to C:\Users\\your_username\Lib\site-packages
  • Create a file python37.pth
  • Edit the file to incorporate this line C:\\Users\\<your_username>\\my_module

The Long version; Do Read


In most cases, editing the PYTHONPATH from the Settings GUI will do the trick. The trick is well explained during this Stack Overflow answer.
If within the first place you’re only looking to edit your path locally, this useful answer will do.

Slightly Extended Item no. 1

If you don’t have C:\Users\\Anaconda3\Lib\site-packages, replace C:\Users\ with the trail to your Anaconda3.

Slightly Extended Item no. 2

If you’re using Python3.7, create a file called python37.pth. Else create a file called python.pth  hon<XX&gt;.pth for whatever Python version you are using.

Not sure which version?

  • Under C:\Users\<your_username>\wikitechy\ search for a file of the form python&lt;XX&gt;.dll. The <XX> indicates the version number you need for naming your .pth file.
  • Windows is super annoying and won’t allow you to create a file with a .pth suffix?
    There are such files within the C:\Users\wikitechy\Lib\site-packages folder. Copy one among them and edit the prefix.
  • Some places say you would like to make a ._pth file rather than .pth?
    A ._pth file will completely replace your existing path. While a .pth file will append its content to the trail you have already got . you’ll find more information here.
READ  How to Replace Bash with Python as Your Go-To Command Line Language

About the author

Wikitechy Editor

Wikitechy Editor

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.