This file describes the operations needed to properly configure a Python development environment in Sublime Text 3, in particular:
- Package Anaconda for autocompletion
- syntax-specific settings
- virtual environment support
The main objective is to make Sublime Text always ready for Python scripting by setting a default interpreter location, but also have the chance to use virtual environments with specific packages.
Mind that this is not intended to be the ultimate way to set Sublime Text, but it is what I personally like. Suggestions are welcome.
Go to Preferences -> Settings
(file named Preferences.sublime-settings
) and use the following descriptors
{
"font_size": 15,
"ignored_packages":
[
"Vintage"
],
"theme": "Adaptive.sublime-theme",
"open_files_in_new_window": false,
"scroll_past_end": true
}
Go to Preferences -> Settings - Syntax Specific
(file named Python.sublime-settings
) and write:
{
"rulers": [80],
"word_wrap": false,
"wrap_width": 80
}
Do not set the Python interpreter here, even if it is correct. We will set in Anaconda (next step)
Once Anaconda has been installed via ST's package installer, go to Preferences -> Package Settings -> Anaconda -> Settings - User
(file named Anaconda.sublime-settings
) and write:
{
"python_interpreter": "/path/to/your/main/python/interpreter",
"anaconda_linting": false,
"complete_parameters": true,
"complete_all_parameters": false
}
My suggestion is to specify here the default location so that ST is always ready for a quick python script: Anaconda will search for the specified path to retrieve the additional python libraries and instantiate autocompletion on your code. You can specify a virtual environment as well.
For projects that are more complex and require a virtual environments, Anaconda can be set so that the local (venv) interpreter is taken into account instead of the main Python interpreter previously specified.
IMPORTANT: this must be done for every project that requires a virtual environment.
Go the folder that contains your project (it should also contain the linked venv
folder) and create a new file called <filename>.sublime-project
Copy paste the following instructions:
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings":
{
"python_interpreter": "/full/path/to/project/venv/python/interpr"
}
}
Now save this file and close all. Reopen Sublime Text, click on Project -> Open Project...
and select the .sublime-project
file just created. From now on, Anaconda will use the additional libraries stored in the local project's venv
folder. If you edit this file, you might notice that information on build source has been added on top of it.