Skip to content Skip to sidebar Skip to footer

How To Run Code In Sublime Text 2 Python

I recently installed sublime text 2 to try it out before I decide to get sublime text 3 but I can't properly run any code from it. I've hit Ctrl + B and I get an output like this.

Solution 1:

Instead of adding python to the path, I prefer simply specifying the full path to python in the sublime build. Python.exe is probably installed in one of these (or something similar)

C:/PythonC:/Program Files/PythonC:/Program Files (x86)/Python
etc...

Once you found it (lets say its in C:\Program Files (x86)\Python27) edit the sublime_build for python. Here is the build I use:

{
    "cmd": ["C:\\Program Files (x86)\\Python27\\python.exe","-u","$file"],
    "selector": "source.python"

}

for me, this file is in

Sublime Text\Data\Packages\Python\Python.sublime-build

Solution 2:

Windows is unable to find your python installation. When you run a command like:

python <your_file.py>

the first python tells your system to find wherever your python binary is and try to run some command by that name. By looking over the path that was echoed, it doesn't look like you actually have your python binary on your system path.

If you're uncertain as to how to add python to your path, check out this superuser question: https://superuser.com/questions/143119/how-to-add-python-to-the-windows-path

Post a Comment for "How To Run Code In Sublime Text 2 Python"