問題描述
我喜歡 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 - Anaconda
和 IPython - Anaconda
菜單選項用于使用 Anaconda 解釋器啟動 REPL.如果您安裝了多個 Python 版本(例如,2.7 和 3.3),您只需復制 children
內容并更改 caption
和 cmd
適當的路徑.
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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!