1import sys
2from os.path import abspath, dirname
3
4sys.path.insert(0, dirname(dirname(abspath(__file__))))
5
6path1 = dirname(abspath(__file__)) # current folder
7path2 = dirname(path1) # parent folder
8
9print(path1)
10print(path2)
1To add Python to the Windows Path, follow these steps:
2
31. Start the Run box and enter sysdm.cpl
42. In the System Properties window go to the Advanced tab and
5 click the Environment Variables button
63. In the System variable window, find the Path variable and
7 click Edit
84. Position your cursor at the end of the Variable value line
9 and add the path to the python.exe file, preceeded with
10 the semicolon character (;)
1# On linux
2$ which python; # Get Path of the executable
3$ export PATH=$PATH:{PATH_PYTHON}; # but it isn't continue
4# ----------------------
5$ which python; # Get Path of the executable
6export PATH=$PATH:{PATH_PYTHON}; # add in your ~/.bashrc or your ~/.zshrc
1app_path = os.path.join(root_path, 'other', 'dir', 'to', 'app')
2os.environ["PATH"] += os.pathsep + app_path