Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick and Dirty Python 2.7 in Sublime Text 3
[
{"keys": ["shift+ctrl+alt+b"], "command": "repl_open",
"caption": "Python2 - RUN current file",
"id": "repl_python2_run",
"mnemonic": "R",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/Users/your-name-here/anaconda/envs/python2/bin/python", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python2"
}
}
]
@flacle

This comment has been minimized.

Copy link
Owner Author

commented Oct 17, 2017

You can copy and paste this Gist when you want to easily add a keyboard shortcut to execute scripts in a different version of Python with the package SublimeREPL. In this case, Python 2.7. Here I'm using Anaconda with a different environment for hosting Python 2.7. I also didn't see the need to edit the configuration of SublimeREPL to add a custom menu item for Python 2.7 in the user interface.

You can paste this Gist in Sublime -> Preferences -> Key Bindings -> Default (OSX).sublime-keymap -- User. Change your-name-here to your actual account name on the OS.

Note: Key bindings do not work when removing "encoding": "utf8" from the arguments list. Copy & paste as is for a first try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.