Sublime-text2:模拟IDLE

时间:2013-06-25 13:58:47

标签: sublimetext2 sublimetext sublimerepl

IDLE没有任何问题,但在功能和易用性方面缺乏很多。

我想让Sublime-text2像IDLE那样表现。右边有一个窗口,我的代码和左边的交互式python控制台。我能够通过在编辑器中安装包控件和sublimerepl来实现这一点。接下来我想绑定F5以在sublimerepl控制台中运行我的脚本。我找到了一个帖子,然后跟着these instructions。不幸的是我得到了this error。我认为错误是由于Windows机器,因为Linux工作正常。

F5绑定的插件代码:

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 }) 

如何修改插件代码,以便按预期在Windows上按F5进行操作?

1 个答案:

答案 0 :(得分:1)

<强>已更新

确保您在PATH环境变量中拥有Python可执行文件。

在我的案例中,将C:\Python27\添加到PATH解决了这个问题。当然,您可能有不同的路径:)

有更好的解决方案

根据https://github.com/wuub/SublimeREPL/issues/96

你可以去Settings -> Package Settings -> SublimeREPL -> Settings - User 并添加此选项:

{
    "default_extend_env": {"PATH": "{PATH};C:\\Python27"}
}
相关问题