Sublime Text for Python - mikec964/chelmbigstock GitHub Wiki
Configure your Mac so that when you double-click a .py file, it opens Sublime.
Configure Python2 and Python3 Build Systems
Configure Sublime so that you can switch between Python2 and Python3 for builds. When you set this, you can press command-B (on a Mac) in the editor and it will run your program. (Instructions inspired by this page, which has great screen shots.)
- First, make sure Sublime is running the correct Python2 by default.
1. In the Sublime Text 2 app, go to Preferences > Browse Packages > Python.
2. Edit the Python.sublime-build file.
3. Comment out this line:
//"cmd": ["/usr/local/bin/python", "-u", "$file"],
(Add the //.) 4. Add this line:"cmd": ["/usr/bin/env", "python", "-u", "$file"],
(Don't forget the comma.) 5. Save the file, open a simple Python2 program, and see if command-B works. - Now, copy the contents of the preference file you used in the prior step.
1. In the Sublime Text 2 app, go to Tools > Build System > New Build System...
2. Paste into the blank file.
3. Change the line to be
"cmd": ["/usr/bin/env", "python3", "-u", "$file"],
4. Save as Python3. 5. If you ever need to edit this file again, you'll find it in ~/Library/Application Support/Sublime Text 2/Packages/User. - When you are working in Python, in the Sublime app look under Tools > Build System and you should be able to selected between Python and Python3.
Other settings
Setting up Sublime Text for Python. I haven't done all of these, but installing the lint tool was helpful.