Frage

The Sublime text 2.0.1 (Mac OSX) build command ignores the shebang line a the top of my python file. The shebang line has the full path to my python 3.2 installation :

#!/usr/local/bin/python3

However the python version being used is always 2.7.2. I'm maintaining code for both 2.7 and 3.2 and so must rely on the shebang line to be used.

Is there a way to configure the Sublime text 2 build system to look at the shebang?

War es hilfreich?

Lösung

Sublime does not use the shebang to determine the execution, it uses your build rule. You could customize the Python build rule to add variants for python2 and python3.

Note that with build variants, the default is run by Command+B (Mac) or Control+B (Windows and Linux). The second variant can be run Command+Shift+B (Mac) or Control+Shift+B (Windows and Linux).

Andere Tipps

Have a look at Sublime Text Shebang plugin.

It adds a few commands that allow to run scripts, based on the shebang line, but the output will be placed on a new buffer, not in the console.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top