Sublime Text 2 REPL使用用户插件运行iPython文件

时间:2014-02-04 01:33:05

标签: sublimetext2 ipython sublimerepl

我试图在Sublime Text 2的交互式shell中运行一个iPython文件。这是我写的第一个插件。

这是我到目前为止所拥有的:

import sublime, sublime_plugin

    class IpydevCommand(sublime_plugin.WindowCommand):
        def run(self):
            self.window.run_command('repl_open',{"type": "subprocess",
                                                 "encoding": "utf8",
                                                 "cmd": ["ipython", "-i", "$file_basename"],
                                                 "cwd": "$file_path",
                                                 "syntax": "Packages/Python/Python.tmLanguage",
                                                 "external_id": "ipython",
                                                 })
            self.window.run_command('move_to_group', { "group": 1 }) 

这里的问题是我之后没有获得互动环境。视图都搞砸了。任何想法如何解决这个问题?

由于

1 个答案:

答案 0 :(得分:0)

您可以使用键盘绑定中的以下配置直接调用ipython,而不是运行笔记本: -

[

{“keys”:[“f9”],“command”:“repl_open”,                      “标题”:“Python - IPython”,                      “id”:“repl_python_ipython”,                      “助记符”:“p”,                      “args”:{                         “type”:“subprocess”,                         “encoding”:“utf8”,                         “autocomplete_server”:是的,                         “cmd”:{                             “osx”:[“python”,“ - u”,“$ {packages} /SublimeREPL/config/Python/ipy_repl.py”],                             “linux”:[“python”,“ - u”,“$ {packages} /SublimeREPL/config/Python/ipy_repl.py”],                             “windows”:[“python”,“ - u”,“$ {packages} /SublimeREPL/config/Python/ipy_repl.py”]                         },                         “cwd”:“$ file_path”,                         “syntax”:“Packages / Python / Python.tmLanguage”,                         “external_id”:“python”,                         “extend_env”:{                             “PYTHONIOENCODING”:“utf-8”,                             “SUBLIMEREPL_EDITOR”:“$ editor”                         }                     }                     }  ]

因此,通过单击F9,它将在新shell上打开ipython