by Dalya Gartzman
How to edit
PYTHONPATH on Windows
You are here because you are using:
- Windows OS version 10+
- Python version 3.3+
And you would like to edit your
- Go to
- Create a file
- Edit the file to include this line
The Long version; Do Read
In most cases, editing the
PYTHONPATH from the Settings GUI will do the trick. The trick is well explained in this Stack Overflow answer.
If in the first place you are only looking to edit your path locally, this helpful answer will do.
Slightly Extended Item no. 1
If you don’t have
place C:\Users\<your_username> with the path to your Anaconda3.
Slightly Extended Item no. 2
If you are using Python3.7, create a file called
python37.pth. Else create a file called
python<XX>.pth for whatever Python version you are using.
- Not sure which version?
C:\Users\<your_username>\Anaconda3\ search for a file of the
t;.dll. The <XX> indicates the version number you nee
d for naming your .pth file.
- Windows is super annoying and won’t let you create a file with a
There are such files in the
C:\Users\<your_username>\Anaconda3\Lib\site-packages folder. Copy one of them and edit the prefix.
- Some places say you need to create a
._pthfile instead of
._pthfile will completely replace your existing path. While a
.pthfile will append its content to the path you already have. You can find more information here.
Slightly Extended Item no. 3
SuperCoolClass you wish to import is located at
Then open your newly created
python<XX>.pth file with your favorite text editor (please don’t say it’s Vim) and add one
Yes, with those annoying dou
ble slashes \\ .
hout quotes "" .
And that’s it.
Now you can import from anywhere, like a normal person:
from my_awesome_file import SuperCoolClass .
Nothing important to add here really.
I just hope my 2 hours of frustration + 1 hour of writing this post saved you some time.