Sublime Text 3不使用默认的python

时间:2014-01-08 05:05:44

标签: python ide sublimetext3 canopy sublimerepl

我最近在我的电脑上安装了sublime text 3(Ubuntu 13.10)。我还安装了Canopy Enthought并将canopy设置为默认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没有问题,终端i可以访问Canopy python 2.7.3以及使用python 2.7.3进行ipython但是在sublimeREPL中打开python2.7.5 +(Ubuntu“old”默认值)。 有一些地方我可以改变这个吗?我尝试重新安装Sublime Text 3,但它没有解决问题。

TERMINAL:

    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.
    >>> 

2 个答案:

答案 0 :(得分:2)

使用以下内容创建一个新文件:

[
     {
        "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菜单。

答案 1 :(得分:1)

谢谢,实际上解决了这个问题!现在我也能用ctrl + shift + i打开ipython-Canopy。如果有人在这个配置中使用我的Key Bindings-用户下面的话:

[{ "keys": ["ctrl+shift+i"],                    
                     "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"
                        }
                    }},
{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } },
]