I wanted to run python in sublimetext2 so I choose the build system as python then I went through this site to install the package control I used the manual instruction for installing the package I don't know how to restart the sublime text2 and pressing ctrl+B doesn't show me anything I tried to print "hello world" but it shows me nothing. what can I do to make it work?I searched a lot in stackoverflow questions like this but still I have problem Thanks.
-
why -1? I really coudn't find my problem in stackoverflow! at least give me a reason – Nickool Dec 06 '12 at 12:38
-
I didn't `-1`'d you but you didn't search hard enough http://stackoverflow.com/questions/8551735/how-do-i-run-python-code-from-sublime-text-2 – zenpoy Dec 06 '12 at 12:42
-
@zenpoy I saw this link before and I tried them! I swear – Nickool Dec 06 '12 at 12:42
-
ctrl+B is not working but it didn't explain how I should make it working – Nickool Dec 06 '12 at 12:43
-
did you save the file and verified the syntax is set to Python? – zenpoy Dec 06 '12 at 12:45
-
yes I saved a .py file in my desktop and then I opened it in IDE and press ctrl+B but it doesn't show any error nor any thing else just a white rectangle in the bottom – Nickool Dec 06 '12 at 12:48
-
if I have 2 other IDEs will it influence it's work? will it cause any problem? – Nickool Dec 06 '12 at 12:49
-
I have no idea, it "just" works for me when I hit ctrl+B... (I have multiple IDE's, multiple python versions, etc.) – zenpoy Dec 06 '12 at 12:50
-
I'm a very newbie in python and I was very enthusiastic about sublimetext but I really don't know how to make it done I followed the instructions but nothing ran as a build result – Nickool Dec 06 '12 at 12:53
3 Answers
I'll try to help you, though according to the comments it seems hopeless. Follow these steps:
open sublime, go to
Preferences
->Browse Packages...
, Open the directory namedPython
and open the filePython.sublime-build
(drag it to sublime)It should look like this:
"cmd": ["python", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python"
Open command line (or any console, in case you are not working in Windows) and type the first value in the 'cmd' list, namely:
python
and press enter.if you get an error than you have to make sure that python is in your environment path, re-install python if necessary.
after making sure that python is in your system's path, restart sublime (or even restart your computer to make sure that the new environment vars loaded)
in sublime press
ctrl+n
to open new tab, enter the following string:print "hello sublime!"
press enter, now pressctrl+s
and save the file somewhere.still in sublime press
ctrl+shift+p
and type inpython
selectSet Syntax: Python
go to
Tools
->Build System
and make sureAutomatic
is checked.press
ctrl+b
, you should see something like
Good luck!

- 19,490
- 9
- 60
- 87
-
Thank you so much!in step3 I got error but in another IDEs I coud run my python so what should I do? – Nickool Dec 06 '12 at 13:17
-
either change the build file for Python to match your python executable or re-install python so that `python` will invoke python. read step 4... – zenpoy Dec 06 '12 at 13:20
-
-
I found something,I set the path in environment variables and now my python will run directly from commandline seems I am near to success :) – Nickool Dec 06 '12 at 13:54
-
I followed your instructions totally and still I don't have any result,I am really exhausted:( and tired – Nickool Dec 06 '12 at 14:36
I just faced the same problem and couldn't understand why it is not working. Then I looked at the console log (View->Show Console) and saw that Sublime Text couldn't encode an "umlaut" properly (Unicode character U+0308). This issue was because I had a folder called "Übung" and ST couldn't handle the "Ü". So I did the following:
- Closed the file and quit Sublime Text
- Checked every folder name in the path to the file I wanted to execute.
- Changed the name of the folders containing non-ascii characters
- Opened Sublime Text and the file again
- Tool->Build
And it worked for me. I hope this can help.

- 21
- 1
In my case the problem was due to SublimeText\Data\Packages\Default\exec.py (First I checked that python was recognized in my system console).
Then, I modified 1 line in this file(exec.py) according ByScripts solution and the problem was solved.

- 71
- 3