use conda environment in sublime text 3

BolzanoW picture BolzanoW · Jan 19, 2016 · Viewed 23.9k times · Source

Using Sublime Text 3, how can I build a python file using a conda environment that I've created as in http://conda.pydata.org/docs/using/envs.html

Answer

MattDMo picture MattDMo · Jan 19, 2016

A standard Python .sublime-build file looks like this:

{
    "cmd": ["/path/to/python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

All you need to do to use a particular conda environment is modify the path to the python or python3 executable within the environment. To find it, activate your environment and type (depending on the version you're using)

which python

or

which python3

on Linux/macOS, or

where python

on Windows, then copy the path into your custom .sublime-build file. Save the file in your Packages/User directory, then make sure you pick the right one via Tools -> Build System before building.