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.
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}"}
}
But a greater dream was to run Anaconda on sublime text. Here is how you do it on windows! Sublime text provides build options by default. It's pretty intelligent in the sense that if you install python, it'll try to get the path to the executable. To inspect how python configures build systems, let us try building a new one
In this tutorial you learned how to set up Sublime REPL and link it to your conda environment. In this way you can have several environments across projects and switch easily with Sublime’s Project Manager and its shortcut CTRL+ ALT+p. Have fun with your new setup and enjoy your projects!
SublimeREPL adds itself as a submenu in Tools. You can choose any one of the preconfigured REPLs and if it’s available in your SYSTEM PATH [1], it will be launched immediately. Second and more user friendly way to launch any given REPL is through Command Palette. Bring up Command Palette and type “repl”.
First I use ubuntu 14.04, so already have Python 2.7 and 3.4. I use Sublime Text 3 like an editor, with SublimeREPL for console mode. At this point, SublimeREPL has as default the version 2.7, this is wat I want to change for the 3.4 v.
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"
}
}
}
]
}
]
}]
}
]
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With