Setting up a Python Development Environment in Sublime Text
Based on Corey Schafer's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Install Sublime Text 3 and verify basic Python execution using Tools → Build (Command+B on macOS) before adding complexity.
Briefing
Setting up a Python workflow in Sublime Text hinges on three layers: installing Package Control, applying editor-wide preferences (themes, fonts, and behavior), and adding a Python-focused package that brings linting and auto-formatting. Once those pieces are in place, Sublime Text can run Python code and provide “IDE-like” feedback—catching common syntax and naming mistakes as code is edited.
The process starts with installing Sublime Text 3 from the official download page. The license model is evaluation-first: Sublime Text can be downloaded and used indefinitely for testing, with periodic purchase prompts if it isn’t licensed. After installation on macOS (dragging the app into Applications), a sample Python module is used to confirm basic execution. Sublime Text’s default “automatic” build system can run the current file via Tools → Build (Command+B on macOS), producing output from the script and demonstrating that a fresh install already supports running Python.
From there, the setup becomes more customized. Package Control is installed through the Command Palette (Tools → Command Palette, or Command+Shift+P on macOS). With Package Control available, additional packages are installed to improve the editing experience. For visual styling, the workflow installs Predon as a color scheme and Material Theme as the interface theme, then pulls recommended and personal settings from a GitHub-hosted configuration into Sublime Text’s user settings. The settings update changes the entire editor appearance, and the author restarts Sublime Text to ensure the changes fully apply. Key preferences include selecting Source Code Pro as the font (from Google Fonts), enabling scroll past the end, converting tabs to spaces for consistency, and suppressing some on-screen popups (like definitions/errors) to reduce interruptions.
Next comes functionality. Several quality-of-life packages are added: Bracket Highlighter to visually match opening and closing braces across lines, and Sidebar Enhancements to expand sidebar actions such as searching and opening files. The Python-specific upgrade is the Anaconda package for Sublime Text (distinct from the Anaconda Python distribution by Continuum Analytics). Its configuration turns on auto-formatting to keep code PEP 8 compliant when possible, with ignore lists for specific PEP 8 checks (including E501 for line length). Linting and error markers appear in the gutter; the author demonstrates missing colons and incorrect variable names producing “invalid syntax” and “undefined name” warnings that disappear once the code is corrected.
Finally, the workflow addresses running different Python versions. Sublime Text’s build systems can be duplicated and customized so projects use Python 2.7 or Python 3.5 instead of the default interpreter. The author creates new build system files (saving them with the Sublime Build extension) and shows that selecting the Python 3.5 build system runs the script using a user-local Python 3.5 path. If packages ever need to be removed, the Command Palette supports “Remove Package.” The result is a reproducible editor environment that supports theming, formatting, linting, and version-specific execution—without forcing users into a full IDE replacement.
Cornell Notes
A practical Sublime Text Python setup combines editor customization with Python-aware tooling. After installing Sublime Text 3 and confirming basic execution via Tools → Build (Command+B on macOS), Package Control is installed through the Command Palette (Command+Shift+P). Themes and color schemes (Material Theme and Predon) are applied via user settings, with preferences like Source Code Pro, scroll-past-end, and tab-to-spaces enabled. Python linting and auto-formatting come from the Anaconda Sublime Text package, configured to format toward PEP 8 and to ignore selected checks (e.g., E501). For multiple interpreters, separate build systems are created for Python 2.7 and Python 3.5 so running code uses the intended version.
Why install Package Control before adding Python packages?
What’s the practical difference between a theme and a color scheme in Sublime Text?
How does the Anaconda Sublime Text package improve day-to-day Python editing?
How are PEP 8 warnings managed when the author doesn’t want to follow every rule strictly?
How does Sublime Text run different Python versions for different projects?
What’s the quickest way to undo an installed package?
Review Questions
- What sequence of steps turns a fresh Sublime Text install into a Python editor with linting and formatting?
- How would you configure Sublime Text to use a different Python interpreter for a specific project without changing your system-wide Python?
- Which settings in the Anaconda configuration control auto-formatting behavior and which control which PEP 8 warnings are ignored?
Key Points
- 1
Install Sublime Text 3 and verify basic Python execution using Tools → Build (Command+B on macOS) before adding complexity.
- 2
Use Package Control (installed via the Command Palette) to manage all additional Sublime Text packages.
- 3
Apply editor-wide preferences through user settings—not default settings—to avoid losing changes after updates.
- 4
Use Material Theme and Predon to separate interface styling (theme) from code syntax coloring (color scheme).
- 5
Add Bracket Highlighter and Sidebar Enhancements to improve navigation and reduce brace-matching mistakes.
- 6
Enable the Anaconda Sublime Text package to get auto-formatting toward PEP 8 and gutter-based linting feedback.
- 7
Create separate Sublime build systems for Python 2.7 and Python 3.5 so running code uses the intended interpreter version.