A environment variable is a way of saving sensitive data such as passwords outside of your Python code. You save the variable in your user profile on your machine and then call the variable from Python, this means that if you share your code or someone looks over your shoulder when coding, they cannot see your passwords in the code.
CREATING THE VARIABLE IN BASH
Bash is simply a Command Line User Interface that is used by some Operating Systems, recently various versions have been created such as bashrc and zsh for Mac Catalina, however they all provide an environment to edit your local profile script. In this script you can store your sensitive details such as user names and passwords, it is stored locally so keeps them private to you.
CALLING THE VARIABLE IN PYTHON
Once you have created the variable in your profile it is easy to call the variable in your Python script. In this example the profile set up in bash contains the password stored in a variable 'myPassword', then the Python script assigns this to a variable called 'password'.
userName = os.environ.get("myUserName")
password = os.environ.get("myPassword")