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.exeis present. In my case,C:\Program Files\Python38 -
Rename your
python.exeto something likepython3.exe. I’m renaming it topython38.exebecause it’s v3.8 -
Create a file called
python.batin 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.