Possible to switch between python 2 and 3 in Sublime Text 3 build systems? (Windows)
<p>All my current coding has been in python 3, which I've installed via the Anaconda package. However I need to work on some code simultaneously in python 2. Is there a way I can add a build system in Sublime so I can switch between the two fluidly? I have both python 2 and 3 installed, however can't see a way of simply editing the build system slightly to switch between the two languages. The build system I'm using for python 3 is:</p>

<pre><code>{
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell": true
}
</code></pre>

<p>Thanks very much!</p>

<p>Specify the absolute path to the version of Python. For example, if Python version 3 is located at <code>/usr/bin/python3</code> and Python version 2 is located at <code>/usr/bin/python2</code>:</p>

<p>Python 3 Build Configuration:</p>

<pre><code>{
    "cmd": ["/usr/bin/python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell": true
}
</code></pre>

<p>Python 2 Build Configuration:</p>

<pre><code>{
    "cmd": ["/usr/bin/python2", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell": true
}
</code></pre>

<p>Find the location of Python via <code>which</code>:</p>

<pre><code>$ which python
/usr/bin/python

$ which python3
/usr/bin/python3

$ which python2
/usr/bin/python2
</code></pre>

<p>See <a href="http://stackoverflow.com/a/40004464/934739">Build system of Sublime Text 3 executes a different version of PHP</a>, it is the same principal.</p>

python sublimetext3