title: How to Identify the Python version in #! using environment variables
body: <p>I have a problem which is caused by our encapsulated design.  Up till now lots of our scripts were written in bash and as a result the <code>#!/bin/bash</code> was always simple.</p>
  
  <p>However now that we are rewriting our scripts in python that is a bit more difficult.  We deliver a specific version of python (to avoid version differences in client installed environments from breaking our implementation).  Because the specific version of python lives in a installed directory structure I need to route to it.</p>
  
  <p>However I don't think the #! statement can accept environment variables from the shell that executes the file(tried and got a bad interpreter).  </p>
  
  <p>eg:</p>
  
  <p>in <code>foo.py</code> I have <code>#!$dirloc/wherepythonlives/python</code></p>
  
  <p>In the bash shell I executed the file and got bad interpreter.
  Is there a way of sneaking an environment variable into that <code>#!</code> line?</p>
  
  <p>Or will I have to depend on an explicit path?  We want to support multiple versions of our software (which may mean multiple python versions) on one environment so I was hoping to somehow keep Python's <code>!#</code> statement inside the directory level we install into.  </p>