Setting current path to `PYTHONPATH` permanently
A neat trick to always include the current working/running directory in PYTHONPATH
.
Windows
-
Go to the folder where your
python.exe
is present. In my case,C:\Program Files\Python38
-
Rename your
python.exe
to something likepython3.exe
. I’m renaming it topython38.exe
because it’s v3.8 -
Create a file called
python.bat
in that same folder and put the following:
%echo off
set PYTHONPATH=%CD%;%PYTHONPATH%
python38 %*
That’s it. Now whenever you’re running python
command, the current directory will be included in PYTHONPATH
by default.