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.

TL;DR

  • 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

Prologue

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.

Categorized in: