【问题标题】:Sublime Text 3 its not using default pythonSublime Text 3 不使用默认 python
【发布时间】:2014-01-26 01:38:11
【问题描述】:

我最近在我的电脑(Ubuntu 13.10)中安装了 sublime text 3。而且我还安装了 Canopy Enthought 并将 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 以及使用 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.
    >>> 

【问题讨论】:

    标签: python ide sublimetext3 canopy sublimerepl


    【解决方案1】:

    创建一个包含以下内容的新文件:

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

    【讨论】:

      【解决方案2】:

      谢谢你确实解决了这个问题!现在我也可以用 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 } },
      ]
      

      【讨论】:

        猜你喜欢
        • 2016-10-28
        • 1970-01-01
        • 2015-01-05
        • 2016-05-02
        • 2013-12-15
        • 2014-07-17
        • 2015-09-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多