I am able to set python3.2 for the build command in sublime text 2(and build with python3.2), but when invoking the console with cmd-` the interpreter is mac's default 2.6 version. Any help is greatly appreciated!
The console in Sublime Text 2 uses the internal version of Python, which is 2.6. There is no way to change it without breaking a whole bunch of stuff. There is a workaround, though. If you just want a Python console within ST2, use the awesome SublimeREPL package, which can also be installed through Package Control. Among many other things, you can send selections or whole files to be interpreted through a REPL of your choice, including Python 3. Create Packages/User/SublimeREPL/config/Python/Main.sublime-menu
with the following contents:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Python",
"id": "Python",
"children":[
{"command": "repl_open",
"caption": "Python 3",
"id": "repl_python3",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python3", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
}
]
}]
}
]
changing the "cmd"
option to the full path to your python3
binary. This way your changes will survive any SublimeREPL upgrades. BTW, this path works for any package, so you can feel free to customize away without fear of accidentally losing it all.
Cmd+` is supposed to open Sublime Text's embedded interpreter console, i.e. the one that you use when developing or debugging Sublime plug-ins. You can verify that by noticing that the sublime
module is available.
If you really want Python 3 console there, upgrade to Sublime Text 3 which embeds Python 3.3. Alternatively, use a dedicated plug-in like SublimeREPL (see @MattDMo's answer).
And BTW: If you want a nice environment for interactive Python work, I suggest to disregard the above and give IPython Notebook a shot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With