Building Python in Sublime Text

Trautlein picture Trautlein · Feb 23, 2013 · Viewed 13.4k times · Source

I am unable to get a Python system to build on a friend's computer which runs Windows XP SP3 using Sublime Text 2. We reinstalled Python 2.7.3 and also Sublime Text 2 and still are having trouble with this. Our Python.sublime-build field says:

{
    "cmd": ["C:\\Python27\\python.exe", "-u", "$(FULL_CURRENT_PATH)"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

When we try to build simple Python programs, such as:

2 * 2

Sublime Text will not build the system, and will instead spit out:

C:\Python27\python.exe: can't find '__main__' module in ''
[Finished in 0.1s with exit code 1]

It would be wonderful if I could get some help with this. Thank you so much whoever assists me with this!

Answer

Clint Powell picture Clint Powell · Apr 6, 2013

I fixed this by saving my file as a .py file. I opened up a new file, added some code, and tried to build it, which gave me that error. After saving as a .py file, I was able to build and run fine.