我喜欢 Sublimetext 中的 Python,但我真正需要的是用于数据探索的交互模式。但是,对于我的生活,我无法让 SublimeREPL 使用 Anaconda 的解释器。任何想法,将不胜感激。
我已将以下内容添加到我的 SublimeREPL.settings.user 文件中,但它没有任何效果:
{
"default_extend_env": {"PATH": "Users/anton/anaconda/envs/py3k/bin/python3:{PATH}"}
}
我喜欢 Sublimetext 中的 Python,但我真正需要的是用于数据探索的交互模式。但是,对于我的生活,我无法让 SublimeREPL 使用 Anaconda 的解释器。任何想法,将不胜感激。
我已将以下内容添加到我的 SublimeREPL.settings.user 文件中,但它没有任何效果:
{
"default_extend_env": {"PATH": "Users/anton/anaconda/envs/py3k/bin/python3:{PATH}"}
}
在您的Packages/User
文件夹中,SublimeREPL/config/Python/Main.sublime-menu
使用以下内容创建:
[
{
"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 上,请使用 single/
作为路径分隔符,或使用 double \\
:
c:/Anaconda/bin/python.exe
# or
c:\\Anaconda\\bin\\python.exe
保存文件,您现在应该有Tools -> SublimeREPL -> Python -> Python - Anaconda
菜单IPython - Anaconda
选项来使用 Anaconda 解释器启动 REPL。如果您安装了多个版本的 Python(例如,2.7 和 3.3),您可以复制children
内容并适当地更改caption
和cmd
路径。
With the caveat that this is an old question with an accepted answer that makes your problem go away, it doesn't directly answer your question. (I would have made this a comment but I don't have sufficient reputation.)
The reason your user settings line doesn't work is because you're specifying the path incorrectly. You are not including a slash before Users
, so it's a relative path and not absolute, and you are also giving the full path to the Python binary, not the directory containing the binary. Rewriting what you have to:
{
"default_extend_env": {"PATH": "/Users/anton/anaconda/envs/py3k/bin:{PATH}"}
}
should solve your problem. Furthermore, I believe it is best practice to copy the contents of the Default SublimeREPL settings file to the user settings file, and then to add the default_extend_env
line at the end.