Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 and Sublime Text 2 Setup Guide

I am new to Sublime Text 2. Basically I want to setup Sublime T2 as a Python IDE.

I have come across various questions with regards to Python and Sublime T2, but I couldn't find a guide from a beginners perspective. This is what I have done so far:

  1. Installed Python.
  2. Installed Sublime T2.
  3. Installed Sublime Package Control

What steps (e.g. package installations, etc.) should I follow to complete the Sublime Python IDE Setup?

like image 692
Saed Avatar asked Mar 06 '13 20:03

Saed


People also ask

Do I need to install Python before Sublime Text?

You need to install this first before you can install anything. Once installed, you will have the option to select 'Package Control: Install Package'. This will open up a list of available packages for Sublime Text. From here you can install any of the dozens of packages available.

How do I configure Python interpreter in Sublime Text?

For language specific settings, click Sublime Text > Preferences > Settings - More > Syntax Specific - User. Then save the file using the following format: LANGUAGE. sublime-settings. For Python-specific settings, save the file as Python.

Is Sublime Text good for Python?

Sublime Text can be used for much more than Python development and there are many useful tutorials that are not targeted at a specific programming language which are still useful. Super charge your Sublime Text 3 to increase your productivity provides many shortcuts and tricks for using the editor.


2 Answers

Besides Package Control, I use the following packages for Python development:

  • SideBarEnhancements
  • All Autocomplete
  • SublimeCodeIntel
  • GitGutter
  • Pylinter

I found SublimeCodeIntel and Pylinter to be especially helpful for writing Python code in Sublime Text.

Besides installing these packages you should also tweak some of Sublime's preferences. For example, Python can be quite picky about whitespace. Therefore I recommend taking extra care for setting up how Sublime handles whitespace. I'm using these settings (put them in Preferences -> Settings - User):

"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,

If you want to know more, I've written a blog post about setting up Sublime Text for Python development: https://dbader.org/blog/setting-up-sublime-text-for-python-development

like image 123
dbader Avatar answered Oct 17 '22 23:10

dbader


You should be able to select a build system in the tools menu.

screenshot

Then, ctrl + B will build, and pull up the interpreter for you.

EDIT: ctrl + ` will also open your console, without building the project. From there, you can run Python commands with the built-in interpreter.

like image 23
brbcoding Avatar answered Oct 17 '22 22:10

brbcoding