Question

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?

Était-ce utile?

La solution

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"}
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top