title: Python: OSError: [Errno 2] No such file or directory on subprocess.Popen
body: <p>I have added the path to mytool in .bashrc and I could run <code>mytool --help</code> from any path in bash shell. However when when I run the following snippet, I get :</p>
  
  <blockquote>
    <p>File "/usr/lib/python2.7/subprocess.py", line 1249, in
    _execute_child
        raise child_exception OSError: [Errno 2] No such file or directory</p>
  </blockquote>
  
  <pre><code>import subprocess
  
  command_array = ['mytool', '--help']
  
  p = subprocess.Popen(command_array,
                       stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
                      )
  
  for line in iter(p.stdout.readline, b''):
          print(line)
  p.stdout.close()
  </code></pre>
  
  <p>How can I resolve this?</p>
  
  <p>EDIT: When I run the python file from terminal (bash), it works fine. But when I run from PyCharm (debugger) or other shells it is giving the above error. </p>
  
  <p>How do I change my script so that it runs 'mytool' in bash when I run the script from other shells? I need the environment added in .bashrc </p>