Is "python2" / "python3" safe on a script's shebang?
<p>Sometimes I see <code>#!/usr/bin/python2</code> and <code>#!/usr/bin/python3</code> as opposed to simply <code>#!/usr/bin/python</code>. I get the appeal of this approach, you get to explicitly say if you need Python 2 or 3 without doing some weird version checking.</p>

<p>Are these <code>python2</code> and <code>python3</code> standard though? Will they work everywhere? Or is it risky?</p>

<p>I just confirmed I have <code>python2</code> and <code>python3</code> but I am on Cygwin so I wouldn't think this means it's necessarily the same for a lot of others.</p>

<p>As a single point of reference -- I don't have a <code>python2</code> executable on my system:</p>

<pre><code>$ python2
-bash: python2: command not found
</code></pre>

<p>So I would definitely not consider this one to be portable.  Obviously I could still run your script by selecting an executable explicitly:</p>

<pre><code>python2.7 your_script.py
</code></pre>

<p>Or by symlinking <code>python2</code> to <code>python2.7</code>, but the point is that it won't work out of the box for me (and I imagine for a number of other users as well).</p>

python scripting portability shebang