1import os
2
3# Set environment variables
4os.environ['API_USER'] = 'username'
5os.environ['API_PASSWORD'] = 'secret'
6
7# Get environment variables
8USER = os.getenv('API_USER')
9PASSWORD = os.environ.get('API_PASSWORD')
10
11# Getting non-existent keys
12FOO = os.getenv('FOO') # None
13BAR = os.environ.get('BAR') # None
14BAZ = os.environ['BAZ'] # KeyError: key does not exist.
15
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