windows add python to global variabels code example
Example 1: python path to python executable
>>> import sys
>>> print(sys.executable)
C:\path\to\python.exe
Example 2: edit path variable using python
app_path = os.path.join(root_path, 'other', 'dir', 'to', 'app')
os.environ["PATH"] += os.pathsep + app_path