title: Execute a BASH command in Python-- in the same process
body: <p>I need to execute the command <code>. /home/db2v95/sqllib/db2profile</code> before I can <code>import ibm_db_dbi</code> in Python 2.6.</p>
  
  <p>Executing it before I enter Python works:</p>
  
  <pre><code>baldurb@gigur:~$ . /home/db2v95/sqllib/db2profile
  baldurb@gigur:~$ python
  Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
  [GCC 4.4.1] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import ibm_db_dbi
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>but executing it in Python using <code>os.system(". /home/db2v95/sqllib/db2profile")</code> or <code>subprocess.Popen([". /home/db2v95/sqllib/db2profile"])</code> results in an error. What am I doing wrong?</p>
  
  <p><strong>Edit:</strong> this is the error I receive: </p>
  
  <pre><code>&gt; Traceback (most recent call last):  
  &gt; File "&lt;file&gt;.py", line 8, in
  &gt; &lt;module&gt;
  &gt;     subprocess.Popen([". /home/db2v95/sqllib/db2profile"])  
  &gt; File
  &gt; "/usr/lib/python2.6/subprocess.py",
  &gt; line 621, in __init__
  &gt;     errread, errwrite)   File "/usr/lib/python2.6/subprocess.py",
  &gt; line 1126, in _execute_child
  &gt;     raise child_exception OSError: [Errno 2] No such file or directory
  </code></pre>