Set Environmental Variables

When working with login credentials, server addresses, etc you can hide them from git and other viewers by saving them as local environmental variables.


  1. create a .bash_profile if it does not exist yet.
  2. edit the .bash_profile to add or change the variables
  3. activate the .bash_profile

In a terminal/console:

touch ~/.bash_profile
vim ~/.bash_profile
source ~/.bash_profile

To set a new variable in the .bash_profile:

export AWS_KEY=$"foobarkey123"
export AWS_SECRET=$"foobarsecret123"

To use environmental variables in Python:

import os
awsKey = os.environ['AWS_KEY']
awsSecret = os.environ['AWS_SECRET']