Get AI summaries of any video or article — Sign up free
Setting up a Python Development Environment in Sublime Text thumbnail

Setting up a Python Development Environment in Sublime Text

Corey Schafer·
5 min read

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.

TL;DR

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?

Package Control acts as Sublime Text’s package manager. After installing it via the Command Palette (Tools → Command Palette, Command+Shift+P on macOS), the workflow can install third-party packages from within Sublime Text using “Install Package.” That’s how Predon, Material Theme, Bracket Highlighter, Sidebar Enhancements, and the Anaconda Sublime Text package are added without manual copying.

What’s the practical difference between a theme and a color scheme in Sublime Text?

A theme changes the overall interface look of Sublime Text (panels, UI styling), while a color scheme changes syntax coloring for code. In this setup, Material Theme is used for the interface, while Predon is used for code syntax colors.

How does the Anaconda Sublime Text package improve day-to-day Python editing?

Anaconda enables auto-formatting and linting. Auto-formatting is turned on so code is reformatted toward PEP 8 on save when possible. Linting produces gutter markers and messages for issues like missing punctuation (e.g., a missing colon causing an “invalid syntax” warning) and incorrect identifiers (e.g., “undefined name” when a variable is mistyped).

How are PEP 8 warnings managed when the author doesn’t want to follow every rule strictly?

The configuration uses ignore lists for specific checks. E501 (maximum line length) is explicitly remembered as a common one; the author notes they exceed the limit often and prefer not to see constant warnings. Those check codes can be placed into auto-format ignore and PEP 8 ignore settings.

How does Sublime Text run different Python versions for different projects?

By creating separate build systems. The setup keeps the default “automatic” build system for the default Python, but adds new build system files for Python 2.7 and Python 3.5. Selecting Tools → Build System → Python 3.5 changes which interpreter path is used when running the script, verified by printing the Python version (showing 35 for Python 3.5).

What’s the quickest way to undo an installed package?

Open the Command Palette and use “Remove Package.” Sublime Text lists installed packages, and the unwanted one can be removed from there.

Review Questions

  1. What sequence of steps turns a fresh Sublime Text install into a Python editor with linting and formatting?
  2. How would you configure Sublime Text to use a different Python interpreter for a specific project without changing your system-wide Python?
  3. Which settings in the Anaconda configuration control auto-formatting behavior and which control which PEP 8 warnings are ignored?

Key Points

  1. 1

    Install Sublime Text 3 and verify basic Python execution using Tools → Build (Command+B on macOS) before adding complexity.

  2. 2

    Use Package Control (installed via the Command Palette) to manage all additional Sublime Text packages.

  3. 3

    Apply editor-wide preferences through user settings—not default settings—to avoid losing changes after updates.

  4. 4

    Use Material Theme and Predon to separate interface styling (theme) from code syntax coloring (color scheme).

  5. 5

    Add Bracket Highlighter and Sidebar Enhancements to improve navigation and reduce brace-matching mistakes.

  6. 6

    Enable the Anaconda Sublime Text package to get auto-formatting toward PEP 8 and gutter-based linting feedback.

  7. 7

    Create separate Sublime build systems for Python 2.7 and Python 3.5 so running code uses the intended interpreter version.

Highlights

Sublime Text can run Python immediately after a fresh install using the automatic build system, but a real workflow comes from layering Package Control, settings, and Python-specific packages.
The Anaconda Sublime Text package provides PEP 8 auto-formatting and linting that flags issues like missing colons (“invalid syntax”) and mistyped variables (“undefined name”).
Build systems let the same editor run different Python versions by selecting a different build system (e.g., Python 3.5) before building/running.

Topics

  • Sublime Text Setup
  • Python Build Systems
  • Package Control
  • Anaconda Linting
  • PEP 8 Formatting

Mentioned