I will soon start my study on Python while developing my latest website using PHP. This time I wanted to use a different editor ( I have been using Notepad++ for my PHP development). Why not learn a new language and use a new code editor at the same time, right?
So I did some research and decided to use Sublime Text 3.
I installed it, installed the package manager (which is called package control) and installed some popular packages for my development needs. I created my first very simple Python file and hit “CTRL + B” and BAM! Error!! ‘python’ is not recognized as an internal or external command…
This error was annoying because many different solutions existed on the internet and some of them countered each other. Of course, I was able to solve this problem at the end:) Here is what you need to do:
1- First and foremost make sure you have installed Python on your system.
2- Edit one of your environment variables and add the installation directory of Python to it. (Something like “C:\Python34\”)
A-) You can append this directory to either “PATH” under “User variables” or “path” under “System variables” section.
B-) In windows 8 you need to go to Settings -> Control Panel -> System -> Advanced system settings to access the “PATH” and “path” variables.
3- After setting your environment variables you will need to create a file named “Python.sublime-build” and put the JSON code below into it.
"cmd": ["c:/Python34/python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
4- Now save this file under “Data\Packages\User” directory. More info here.
Now the error should be gone and you should be able to run your Python code.
Hope this helps.