0
votes

i installed sublime text3 and tried to run a python code in it. when i choose python from Build system and tried to run the code i got this error :

'python' is not recognized as an internal or external command, operable program or batch file. [Finished in 0.1s with exit code 1] [shell_cmd: python -u "C:\Python26\Lib\py\try66.py"] [dir: C:\Python26\Lib\py] [path: C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn]

so i installed sublimeREPL file and set the path in the file. and the i create a new Build system named python26repl.sublime-build with this context:

> { "target": "run_existing_window_command", "id":  "repl_python_run",
> "file": "config/Python/Main.sublime-menu" }

and i set the Build system to python26repl.sublime-build. now Build (CTRL+B) doesn't work.i mean they do nothing but save the code. please help, what's the problem? how to fix?

3
have you added Python to the PATH Environmental Variable?Nil Sagor

3 Answers

0
votes

The first issue you're having is that the built in Python.sublime-build program is trying to execute python as a command, but it's not able to find it on the path, so Windows generates an error. If you add the appropriate path to python.exe to your PATH environment variable (and restart Sublime), that problem should go away. How you do that depends on what version of windows you're using.

The second problem you have is that SublimeREPL is an older package that is unmaintained, and it's run_existing_window_command command contains a bug that causes it to not work on Windows. Prior to Sublime Text 3.2 the bug was masked by Sublime being somewhat lax about some API violations, so despite the bug it worked anyway, but this is no longer the case.

You'll notice that if you use the menu entries for SublimeREPL instead, it will run your program as expected (assuming you've set it up correctly). If you want a build system that will work, you need to define it something like this:

{
    "target": "repl_open",
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": ["python", "-i", "-u"],
    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}
}

Since python isn't on your path, you may need to tweak this as appropriate for your setup (for example, doing whatever you did when you set up SublimeREPL in the first place).

0
votes

The problem is python path settings. it's not set properly

To set python to Path Environmental Variable,

  1. First click on Start Menu and right-click on My computer, then properties

  2. then click on Advance System Settings

  3. In Advanced tab, click Environment Variables...

  4. then at System variables section, find path and click Edit

  5. and now add ;C:\Python37 (whatever your path) at the the end of the that string and save changes by ok

At command prompt (Win + R, type cmd, then ok), type python and it will show you python console and that's it. you can try your script in Sublime text by pressing Ctrl+B

if it still shows errors , you can try uninstall and then try reinstall again

while reinstalling, check mark on at the bottom of installer interface "Add Python3.7 to Path"

Hope it will help

0
votes

In my opinion, the easiest way to fix this is probably just to install the python 3 app from the windows store (if you're on Windows 10), it downloads to the directory that automatically connects to sublime text, unlike the version you download from python.org which you need to manually connect through which works too.