1

There is nothing wrong with IDLE but it lacks a lot in terms of functionality and ease of use.

I want to make Sublime-text2 behave the way IDLE does. Have a window on the right with my code and an interactive python console on the left. I was able to do this by installing package control and sublimerepl in the editor. Next thing I wanted to bind F5 to run my script in sublimerepl console. I found a thread and followed these instructions. Unfortunately I am getting this error. I assume the error is due to windows machine, since linux works fine.

plugin code for F5 binding:

import sublime, sublime_plugin

class PydevCommand(sublime_plugin.WindowCommand):
    def run(self):
        self.window.run_command('set_layout', {"cols":[0.0, 1.0], "rows":[0.0, 0.5, 1.0], "cells":[[0, 0, 1, 1], [0, 1, 1, 2]]})
        self.window.run_command('repl_open',{"type": "subprocess",
                                             "encoding": "utf8",
                                             "cmd": ["python2.7", "-i", "-u", "$file"],
                                             "cwd": "$file_path",
                                             "syntax": "Packages/Python/Python.tmLanguage",
                                             "external_id": "python2.7"
                                             })
        self.window.run_command('move_to_group', { "group": 1 }) 

How can I modify the plugin code so that hitting F5 would work on windows as intended?

Community
  • 1
  • 1
minerals
  • 1,195
  • 4
  • 15
  • 22
  • Are you remembering to either single quote your path or using double slashes in the path? – Eterm Jun 25 '13 at 14:01
  • neither works, I tried `"Packages\\Python\\Python.tmLanguage"` and `'Packages\Python\Python.tmLanguage'` with full path as well. – minerals Jun 25 '13 at 14:13

1 Answers1

1

UPDATED

Make sure that you have your Python executable in the PATH environment variable.

In my case adding C:\Python27\ to PATH solved this issue. Of course, you might have different path :)

There is a better solution

According to https://github.com/wuub/SublimeREPL/issues/96

You can go to Settings -> Package Settings -> SublimeREPL -> Settings - User And add this option:

{
    "default_extend_env": {"PATH": "{PATH};C:\\Python27"}
}
FreeNickname
  • 7,398
  • 2
  • 30
  • 60
  • I do have python2.7 assigned in SublimeREPL `"default_extend_env": {"PATH": "C:\\Python27"},`. And it works, it is that hitting F5 brings up the error. – minerals Jun 25 '13 at 14:14
  • Then I'm not quite sure what the problem is. But these records seem a bit different to me. Try writing `{"PATH": "{PATH};C:\\Python27"}` instead of `{"PATH": "C:\\Python27"}`. – FreeNickname Jun 25 '13 at 14:16
  • 1
    well, actually you were right, I didn't have python2.7 in my windows path (facepalm). Now all works fine. `C:\Python27\` should be the first in path to use python2.7. – minerals Jun 25 '13 at 15:07
  • :) I'm glad that it helped. Strange... Works in the end of the `PATH` for me. Anyway, it's good that it works somehow :) Good luck! – FreeNickname Jun 25 '13 at 16:17