如何使用 Anaconda 的解释器设置 SublimeREPL?

时间:2023-01-24
本文介绍了如何使用 Anaconda 的解释器设置 SublimeREPL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我喜欢 Sublimetext 中的 Python,但我真正需要的是用于数据探索的交互模式.但是,对于我的生活,我无法让 SublimeREPL 使用 Anaconda 的解释器.任何想法将不胜感激.

I love Python in Sublimetext, but what I really need is an interactive mode for data exploration. However, for the life of me I cannot get SublimeREPL to use Anaconda's interpreter. Any ideas would be appreciated.

我已将以下内容添加到我的 SublimeREPL.settings.user 文件中,但没有任何效果:

I have added the following to my SublimeREPL.settings.user file, but it doesn't have any effect:

{
    "default_extend_env": {"PATH": "Users/anton/anaconda/envs/py3k/bin/python3:{PATH}"}
}

推荐答案

在你的 Packages/User 文件夹中,创建 SublimeREPL/config/Python/Main.sublime-menu内容如下:

In your Packages/User folder, create SublimeREPL/config/Python/Main.sublime-menu with the following contents:

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

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

"cmd" 行中,将 /path/to/Anaconda/python 更改为您要使用的 Python 可执行文件的实际路径.如果您使用的是 Windows,请使用单个 / 作为路径分隔符,或使用双 \:

In the "cmd" lines, change /path/to/Anaconda/python with the actual path to your python executable you want to use. If you're on Windows, either use a single / as path delimiter, or double \:

c:/Anaconda/bin/python.exe
# or
c:\Anaconda\bin\python.exe

保存文件,你现在应该有 Tools ->崇高REPL->蟒蛇->Python - AnacondaIPython - Anaconda 菜单选项用于使用 Anaconda 解释器启动 REPL.如果您安装了多个 Python 版本(例如,2.7 和 3.3),您只需复制 children 内容并更改 captioncmd适当的路径.

Save the file, and you should now have Tools -> SublimeREPL -> Python -> Python - Anaconda and IPython - Anaconda menu options to start REPLs with the Anaconda interpreter. If you have multiple versions of Python installed (for example, 2.7 and 3.3) you can just duplicate the children contents and alter the caption and cmd paths appropriately.

这篇关于如何使用 Anaconda 的解释器设置 SublimeREPL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:未找到 Conda 命令 下一篇:为什么在 conda 安装后 Tensorflow 无法识别我的 GPU?

相关文章

最新文章