title: how to set environment variable from .env file in python script?
body: <p>In the Ubuntu bash shell, I can set the environment variable from the .env file by using command lines "source" (example: <code>source $OCSSWROOT/OCSSW_bash.env</code>). </p>
  
  <p>But <code>source</code> is not a function in python. 
  So, how to set an environment variable from the .env file in python？</p>
  
  <p>'l2gen'is a command line program of SeaDAS which be supported by NASA for processing ocean satellite data. I can run it in the bash shell. now, the more program needs to be coded with python script and 'l2gen' is one of program.</p>
  
  <p>But the environment variable needs to be set again in python script.
  According to the google search result, I fond some method to set the environment variable in python. But lacking information about the .env file. </p>
  
  <p>in the Linux bash shell, I set the environment variable by vim and source:</p>
  
  <pre><code>    vim .profile
      export OCSSWROOT=[SeaDAS_install_dir]/ocssw (adding this in the profile 
                                                   file and then save/exit)
      source $OCSSWROOT/OCSSW_bash.env
  </code></pre>
  
  <p>where: SeaDAS_install_dir is the directory where I installed software SeaDAS.</p>
  
  <p>I try to add the environment variable as following:</p>
  
  <pre><code>import subprocess
  if __name__=='__main__':
       l2cmdtest = 'l2gen -h'
       new_env = os.environ.copy()
       new_env['OCSSWROOT'] = '/usr/local/seadas-7.5.3/ocssw'
       new_env['OCSSWROOT'] = 'OCSSWROOT/OCSSW_bash.env'
       eturnCodetest = subprocess.call(l2cmdtest, shell=True)
  </code></pre>
  
  <p>where: 'l2gen -h' is a program which can work in the bash shell.</p>
  
  <p>executing python script, and then an error:</p>
  
  <pre><code>/bin/sh: 1: l2gen: not found
  </code></pre>