Setup Sublime Text 3 with VirtualEnv

This is a "checklist" to remind me how I setup Sublime Text 3 so it will automatically recognize the virtualenv and find the modules installed in it.

NOTE: This is for MacOS. The paths will be different on Linux or Windows.

  1. Start with a "new" Sublime Text environment.

  2. Install Package Manager - restart

  3. Install Anaconda - restart

  4. Edit the global Anaconda User settings and add this line:

    { "python_interpreter": ""/usr/local/bin/python3"" }

then restart.

Using whichever method you use to create the virtualenv(virtualenv, pipenv, pew, venv, etc.)

  1. Create the virtualenv

  2. In the project directory, create a .anaconda file and add this line replacing <venv> with the name of the virtualenv:

    { "python_interpreter": "~/.local/share/virtualenvs/<venv>/bin/python" }

This will override the python interpreter in the global settings and allow Anaconda to find the modules that are installed in the virtualenv.

NOTE: Sometimes it will take a little while for the dropdown box to display the properties, functions, or classes from the module but wait a few seconds and the list of "I found these in this file" completions will be replaced by "This is probably what you are looking for" completions.

So, the "workflow" now is:

  1. Create the project directory.

  2. Create the virtualenv

  3. Create the .anaconda file, updating it to point to the virtualenv created in step 2

  4. Launch subl .

  5. Open a python file and double check to make sure the build system is "Anaconda Python Builder"