Sublime Text For Python: A Comprehensive Setup Guide
Sublime Text is a code editor that supports multiple programming languages, including Python. It’s known for its speed, ease of use, and strong community support. Here’s a brief explanation of its features and use for Python development.
Python is the one the most popular programming languages across the world. It is an object-oriented, interpreted, and general-purpose programming language. It can be used to make web applications, system automation, machine learning, deep learning, data analysis, etc. In order to utilise all the features of Python, the use of an ideal code editor is a must. Sublime Text is one such amazing code editor. We will be discussing the step-by-step process to set up Sublime Text for Python development and the features that make Sublime Text one of the most powerful code editors.
Table of Content
- What is Sublime Text?
- Why use Sublime Text for Python?
- How to start Python development on Sublime Text?
- Packages for Python developers
What is Sublime Text?
It is said to be the most famous source code editor that provides developers with a platform where they can write and edit code in different programming languages. It supports several operating systems like Windows, Linux, macOS, etc. This was released in January of 2008 and is written in Python and C++. It is fast, efficient, and has robust community support. Although this text supports various programming languages, its support for the Python language is magnificent.
Best-suited Python courses for you
Learn Python with these high-rated online courses
Why use Sublime Text for Python?
While doing Python development, the most supported and recommended code editor is Sublime Text, as it provides three main features for Python development: simplicity, interface, and customization.
- Simplicity: It is light and simple, hence fast. It is specially developed with the goal of providing a smooth experience to users. In this, the code editor comes at the moment you open it, unlike other editors where ads and messages come first. This text also has the special feature of auto-saving the code, so your code is safe and next time you can start from where you left.
- Interface: The interface of such text is the best among all the code editors available in the market. There are no unnecessary side and bottom panels; almost all the space is for the code editor, so users can focus on their code. It also supports multi-projects; new projects will always be opened in a new window, which is very helpful when working with multiple codebases.
- Customization: It is famous for its out-of-the box features like spell checks, key bindings, etc. There is an addon known as “package”, under which we can add custom features to the existing features of this text. Packages are simply plugin extensions that can perform additional tasks.
How to start Python Development on Sublime Text?
Prerequisite: Python must be installed on your devices. If not, download it from “python.org” and install by executing the .exe file.
Now let’s discuss a step-by-step comprehensive guide to set up Python on Sublime Text:
Step 1. Installing Sublime Text on your device
In order to install it on Windows, simply go to “sublimetext”.com and download the free version. To complete the installation process, execute the .exe file.
For installing SublimeText on Linux, follow the below steps:
- Install the Snap using command sudo apt install snapd.
- Now, install Sublime Text using sudo snap install sublime-text-classic.
Step 2. Configuring & Setting up Python on Sublime Text
Now we move to the next step of configuring Python on Sublime Text, for which an integrated terminal is required. Lets focus on installation and configuration of Integrated Terminal.
Open the Sublime Text, click on the Tools section, and then go to “Command Palette”.
Next is to click “Install Package Control” this will install “Package Controller” on your device.
When Package Controller is installed successfully, a pop-up box will appear.
Next step is to install “Terminus”. For this, first type install Package, then select “Package Control:Install Package” from the drop down list.
A new drop-down list will appear, it contains all the packages that can enhance the sublime’s functionality. Type “Terminus” and download it.
Once downloaded, you can view it under Preferences -> Package Settings -> Terminus. Open the “Command Palette” again, type “Terminus”, and select “Terminus:Open Default Shell in Panel” to open the command line of Sublime Text.
Last but not least, the next step is to set up Python in Sublime Text. Open “Command Palette” again, type “Python” and select the “Set Syntax:Python” option.
Now all is set, let’s write the first line of Python code in Sublime Text. Write
print(“Hello World”)
and save this file as “Hello.py”. In order to build and run the Python code, open the “Command Palette” and select “Build with:Python”. This will run your code in the “Terminus” and produce the desired output.
Explore:
Sublime Text packages for Python Developers
Earlier, we installed Terminus and Control packages. Like this, there are many packages available in this type of text that can enhance your Python coding experience. Using the Command Palette, any package can be installed just like we installed Terminus in the above steps.
Package Controller is like the master package for installing the other packages. It is the root for all other packages. Having a package controller is like having a licence to install all the remaining packages to enhance the coding experience.
In order to start Python development in Sublime Text, there are some packages available that will enhance your coding experience, so it’s better to install them. Below are few of them:
- Tabnine: It is an AI-driven package. Tabnine’s main feature is to assist you during coding, reducing the chances of mistakes and errors. Tabnine can support up to 30 different programming languages, and Python is one of them.
- Anaconda: It is a package that is used for syntax highlighting and version management. Anaconda can make the text editor a full-fledged Python IDE as it provides features like code linting, autosave, autocompletion, Docker support, etc.
- Git: This package supports the common git commands in this type of text. Using the Git package, you can perform git operations like add, commit, push, pull, etc.
- Requirementstxt: The requirements.txt package is like an alternative to Anaconda, as it also provides the features of syntax highlighting and version management in Sublime.
- SublimeLinter: The sublimeLinter package is an automated checking package that checks errors and styles in Python code. It is one of the most stable and best linting packages available in Sublime Text. Automatic updates are available in this SublimeLinter.
- GitGutter: The GitGutter package keeps track of all files that have been updated since the last commit. It simply adds a small symbol to the lines that indicates its update since the last git commit.
- Auto Docstring: The autoDocstring package can create Python docstring templates for selected methods. This package adds docstrings for every function in the code file and changes that occurred since the last commit.
- AutoPEP8: The AutoPEP8 package formats the Python code automatically into PEP 8 style coding format. It also helps in key binding.
This is a collection of insightful articles from domain experts in the fields of Cloud Computing, DevOps, AWS, Data Science, Machine Learning, AI, and Natural Language Processing. The range of topics caters to upski... Read Full Bio