Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run Python code from Sublime Text 2?

I want to set up a complete Python IDE in Sublime Text 2.

I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?

like image 822
neo Avatar asked Dec 18 '11 12:12

neo


People also ask

Can I run Python code in sublime?

Yes, you can use Sublime Text 3 to run Python codes as it has basic built-in support. Sublime Text IDE is fast and will also allow you to customize your editor as per your needs in order to help you create a Python development environment.

How do I run code directly from Sublime Text?

Usually you can just select python from Tools>Build System>Python and hit Ctrl+B to run it in the sublime console.

How do I run a Python script?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!


1 Answers

Tools -> Build System -> (choose) Python then:

To Run:

      Tools -> Build        -or-        Ctrl + B        CMD + B  (OSX) 

This would start your file in the console which should be at the bottom of the editor.

To Stop:

       Ctrl + Break or Tools -> Cancel Build         Fn + C (OSX) 

You can find out where your Break key is here: http://en.wikipedia.org/wiki/Break_key.

Note: CTRL + C will NOT work.

What to do when Ctrl + Break does not work:

Go to:

Preferences -> Key Bindings - User

and paste the line below:

{"keys": ["ctrl+shift+c"], "command": "exec", "args": {"kill": true} }  

Now, you can use ctrl+shift+c instead of CTRL+BREAK

like image 82
matiit Avatar answered Sep 21 '22 14:09

matiit