title: Set shell environment variable via python script
body: <p>I have some instrument which requires environment variable which I want to set automatically from python code. So I tried several ways to make it happen, but none of them were successful.
  Here are some examples:</p>
  <ol>
  <li><p>I insert following code in my python script</p>
  <pre><code> import os
   os.system(&quot;export ENV_VAR=/some_path&quot;)
  </code></pre>
  </li>
  <li><p>I created bash script(env.sh) and run it from python:</p>
  <pre><code> #!/bin/bash
   export ENV_VAR=some_path
  
   #call it from python
   os.system(&quot;source env.sh&quot;)
  </code></pre>
  </li>
  <li><p>I also tried <code>os.putenv()</code> and <code>os.environ*[&quot;ENV_VAR&quot;] = &quot;some_path&quot;</code></p>
  </li>
  </ol>
  <blockquote>
  <p>Is it possible to set(export) environment variable using python, i.e
  without directly exporting it to shell?</p>
  </blockquote>