Sublime Forum

When I try to run my python code it says that python isn't an operable program

#1

I am a complete novice and recently downloaded sublime text as my python editor and it says “‘python’ is not recognised as an internal or external command, operable program or batch file.” Does this mean that I have not downloaded sublime text properly, or do I just need to download a separate python editor and patch that to sublime text somehow (and if so could you also explain how, as I said, I am a complete novice.)

0 Likes

#2

You have downloaded Sublime properly, but while it supports Python (and is extendable in that language) it includes it’s own “private copy” of Python that is not externally visible to anything but itself.

As such if you want to execute external Python code you will need to install Python for your operating system. You can get it from https://www.python.org/. It sounds like you’re on Windows (based on that error message you quoted above) so you should be able to download an installer for Windows from that page.

There is a beginners guide to get you up and running, which includes a page on how to download and install it.

0 Likes

#3

Thank you!

0 Likes

#4

I’ve downloaded python, but … it still doesn’t work. I downloaded python 3.5.2 from the python website but when I tried to run the program it still says that python isn’t operable, do I need to download python to a specific location on my computer, or do I just not know how to use sublime text (btw, I am supposed to use Ctrl - B to run the program aren’t I.) I meant B, typo.

0 Likes

#5

Well, Ctrl+B (Ctrl+D is for selecting text), but I assume that was just a typo on your part. :wink:

If it’s still saying that same error message, then the problem is probably that it can’t find where python is actually installed. It doesn’t have to be installed in any particular location, but by default Sublime (like Windows) will only look for programs to run in specific locations.

Your error information may look something like the following (but, you know, with your username in there and not mine ;))

'python' is not recognized as an internal or external command,
operable program or batch file.
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u ""]
[dir: C:\Users\tmartin\AppData\Roaming\Sublime Text 3\Packages\User]
[path: C:\Program Files (x86)\Attachmate\Reflection\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;C:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs\;C:\Users\tmartin\AppData\Roaming\npm;"C:\Program Files\Git\bin"]```

The big list of places in `[path: ...]` is where it's trying to find `python` to be able to run it, so presumably the location that you installed Python to is not included there.  The general fix for this is to add the location of the python binary to the system path. I don't have python installed on any of my windows machines, but [this page](https://docs.python.org/3/using/windows.html#configuring-python) seems to think that the windows installer has an option to modify the path so it should have done that for you unless that option is not checked by default.

The method for adding something to the path is (probably) slightly different depending on what version of windows you happen to be running. I assume the python installer adds items to your start menu so you should be able to figure out where it is using that (perhaps it included a "python command prompt" kind of shortcut?).

When you're done adding it to the path, you should be able to open up a brand new command prompt window and enter "python" and have it do something more interesting than just complain.
0 Likes

#6

Thank you OdatNurd and Dubeg, it now vaguely works!

1 Like

#7

It doesn’t work, please help me

0 Likes

#8

I solved this problem by simply reinstalling it and making sure to select the “Add Python 3.8 to PATH” option in the first screen:

image

0 Likes