崇高文本3它不使用默认的python

2024-05-17 04:04:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近在我的电脑(ubuntu13.10)上安装了sublimetext3。我还安装了Canopy enthough并将Canopy设置为默认python。但是Sublime text没有使用新的默认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作为默认值没有问题,在终端中我可以访问Canopy python 2.7.3和ipython和python 2.7.3,但在sublimeREPL中打开python2.7.5+(Ubuntu“old”默认值)。 有什么地方我可以改变这个?我试图重新安装崇高文本3,但它没有解决问题。在

终端:

^{pr2}$

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

Tags: textccp版本终端whichhomebinipython
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菜单中。在

谢谢你真的解决了问题!现在,我也可以用ctrl+shift+i打开ipython Canopy。如果有人想要这个配置,我的键绑定-用户如下:

[{ "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 } },
]

相关问题 更多 >