0

我正在尝试在 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 }) 

这里的问题是我没有得到一个交互式环境。景色全乱了。任何想法如何解决这一问题?

谢谢

4

1 回答 1

0

您可以在键映射绑定处使用以下配置直接调用 ipython,而不是运行笔记本:-

[

{“键”:[“f9”],“命令”:“repl_open”,“标题”:“Python - IPython”,“id”:“repl_python_ipython”,“助记符”:“p”,“args”:{ “类型”:“子进程”,“编码”:“utf8”,“autocomplete_server”:true,“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”:“包/Python /Python.tmLanguage", "external_id": "python", "extend_env": { "PYTHONIOENCODING": "utf-8", "SUBLIMEREPL_EDITOR": "$editor" } } } ]“cwd”:“$file_path”、“syntax”:“Packages/Python/Python.tmLanguage”、“external_id”:“python”、“extend_env”:{“PYTHONIOENCODING”:“utf-8”、“SUBLIMEREPL_EDITOR”: "$editor" } } } ]“cwd”:“$file_path”、“syntax”:“Packages/Python/Python.tmLanguage”、“external_id”:“python”、“extend_env”:{“PYTHONIOENCODING”:“utf-8”、“SUBLIMEREPL_EDITOR”: "$editor" } } } ]"SUBLIMEREPL_EDITOR": "$editor" } } } ]"SUBLIMEREPL_EDITOR": "$editor" } } } ]

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

于 2014-07-06T12:44:50.823 回答