Am trying to use Sublime Text 3 (Build3211) with Python 3.9.0 on Windows 10. Have downloaded both successfully. Gone to Sublime Text to: Tools - Build System - New Build System.
- Sublime Text 3 Python Autocomplete
- Sublime Text 3 Python Windows
- Sublime Text Plugins
- Sublime Text 3 Python Repl
- Sublime Build Python
I like Sublime because it is lightweight when compared to a fully featured IDE, such as PyCharm or Visual Studio. The long journey home 1 46. I use the command line for searching text with grep, sed, and awk, and I've always felt git should be used at the command line to make sure you're doing what you think you're doing.
In this tutorial we're going to show you how to run python in sublime text 3 on windows. Setting Up Sublime Text 3 for Full Stack Python Development is a spectacular tutorial that covers installing Sublime Text and configuring a multitude of helpful Python programming plugins. Sublime Text 3 Heaven is a quick overview of the extensions, packages and bonus toys that one developer uses for his own Sublime Text development setup. Cntrl + S or save as 'C:Users usernameAppDataRoamingSublime Text 3PackagesUserSublimeREPL-python.sublime-build' updating username or path as needed. This should be wherever your settings and builds are stored by Sublime Text. Go to Tools, Build System, select SublimeREPL-python. All done-now to test. How to Setup Sublime Text 3 with Python and interactive mode - SublimeREPLPython Build Code: 'cmd': 'C:/Program Files/Python35/python.exe', '-u', '$fil.
Here's the set up I use for Sublime.
- First, install package control by follow these instructions.
- Go to the Tools -> Command Palette.
- Type Package Control: Install Package and select it.
- Search for Anaconda and install it. Anaconda gives you a wonderful Python environment: automagically checking for unused package imports and variables, making sure you follow PEP-8 coding style, and common syntax problems. It will make your code much cleaner, readable, and maintainable going forward. I have never seen a syntax highlighter as good the on Anaconda provides.
- Install black on your current system with
pip install black
. Then, search for subblack using Package Control: Install Package, and install it just like you installed Anaconda. Black is an opinionated Python syntax formatted. If you have ugly code, simply hit Control + Alt + B to format it beautifully. - If you'd like autocomplete for Django, you can use Package Control: Install Package to install Djaneiro as well.
- PEP-8, Python's style guide, recommends a maximum line length of 79 characters. I find this too short for modern coding, and prefer Black's default. Go to Preferences > Package Settings > Anaconda > Settings-Syntax Specific-User. A new tab will open in your editor. We also want to explicitly set the path to the correct Python version, especially on Windows, as installing NodeJS may (still, in December 2019, ugh) install Python 2.7. This block also tells Sublime to ignore certain linter warnings to be Black and PEP-8 compatible. Enter the following, save the file, and restart Sublime Text.
Writing consistent, well-formed code is important. Of course the functionality of the code is paramount, yet in addition the styling and structure should follow a commonly accepted standards. Not only will it make the code more approachable to others, but also to yourself, when you return to an old piece of software, which you have not looked at for months or even years. You might even squash some bugs early on, by writing code in consistent manner. The process of styling and checking of these code qualities, is often referred as linting.
Here's one take on the matter, how to lint live on the text editor, as we type.
Here's one take on the matter, how to lint live on the text editor, as we type.
Prerequisites
Some prerequisites, to give us a starting point.
- We are running macOS 10.10+. At the time of writing, I am running
macOS Sierra 10.12.2
. - We have Sublime Text installed. At the time of writing, I am running
ST 3 Dev, build 3125
. - we have Python 3.6 installed. At the time of writing, I am running
Python 3.6.0
installed with Homebrew.
Sublime Text 3 Python Autocomplete
Step One: Install Flake8
To beging linting, we obviously need a linter installed. We are going to install Flake8, which installs pycodestyle aka PEP8 (code style checks), Pyflakes (lint checks) and McCabe (complexity checks).
Sublime Text 3 Python Windows
Note, that the Python version is the key here; If we install Flake8 to a Python version earlier than 3.6, the linting for 3.6 features will not work.
We will install the package to system level, and we are going to do that with the mighty pip
To check, that the linter installed correctly, run the which
command, which should return the path to the executable:
At the time of writing, the versions are as follows:
Sublime Text Plugins
Now, that we have a working linter, let's run it against some poorly crafted code, like this:
And with this we have confirmed, that we cannot code, but our linter is working, so we know what we are doing wrong, and can improve!
Step Two: Install SublimeLinter and Flake8 plugin
First we need to install SublimeLinter to Sublime Text. Do pay attention to version! Since we are running ST3, we are going to install SublimeLinter 3.
The installation should be done with ST's Package Control
. Find the package SublimeLinter
, and install it.
After that sorted, let's continue and install the Flake8 plugin on top of that. Same as before, we do it with Package Control. This time find a package SublimeLinter-flake8
and install it.
We can configure the Flake8 to our liking, with settings in SublimeLinter.sublime-settings
. A very basic configuration might be as follows:
Sublime Text 3 Python Repl
Just to make sure Sublime Text does not begin to act up, let's restart it.
Step Three: Keep on coding
After the previous steps completed, we can see the linting errors and warnings right in Sublime Text and update live as we code.
Sublime Build Python
Now is the time to fix that hideous code, we have been working on. Happy linting!