我最近在我的电脑(Ubuntu 13.10)中安装了Sublime Text 3。我还安装了Canopy Enthought并将树冠设置为默认python。但是Sublime文本而不是使用新的默认python和ipython,而是使用“旧”版本。在Windows中,我曾经使用SublimeREPL运行ipython控制台,而Canopy也没有问题。我在终端中验证了以下结果:

    ~$ which python
    /home/ccp/Enthought/Canopy_64bit/User/bin/python
    ~$ which ipython
    /home/ccp/Enthought/Canopy_64bit/User/bin/ipython


因此,默认情况下Canopy没问题,在Terminal中,我可以访问Canopy python 2.7.3,也可以使用python 2.7.3访问ipython,但在sublimeREPL中打开python2.7.5 +(Ubuntu为“旧”默认值)。
在某些地方可以更改此设置?我尝试重新安装Sublime Text 3,但没有解决问题。

终奌站:

    Enthought Canopy Python 2.7.3 | 64-bit | (default, Dec  2 2013, 16:23:35)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>


PYTHON(SUBLIMEREPL):

    Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
    [GCC 4.8.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

最佳答案

创建一个具有以下内容的新文件:

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "r",
            "id": "SublimeREPL",
            "children":
            [
                {"caption": "Python",
                "id": "Python",

                 "children":[
                    {"command": "repl_open",
                     "caption": "Python - Canopy",
                     "id": "repl_python",
                     "mnemonic": "p",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["/home/ccp/Enthought/Canopy_64bit/User/bin/python", "-i", "-u"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - IPython - Canopy",
                     "id": "repl_python_ipython",
                     "mnemonic": "p",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "autocomplete_server": true,
                        "cmd": ["/home/ccp/Enthought/Canopy_64bit/User/bin/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"
                        }
                    }
                    }
                ]}
            ]
        }]
    }
]


并将其另存为~/.config/sublime-text-3/Packages/User/SublimeREPL/config/Python/Main.sublime-menu。这会将Python - CanopyPython - IPython - Canopy选项添加到Tools -> SublimeREPL -> Python菜单。

10-08 01:17