Python Tutorial

Python Variable

Python Operators

Python Sequence

Python String

Python Flow Control

Python Functions

Python Class and Object

Python Class Members (properties and methods)

Python Exception Handling

Python Modules

Python File Operations (I/O)

Sublime Text Download And Installation Tutorial

Sublime Text is a popular text editor that is small, fast, and powerful for text, running on Windows, Linux, and Mac OS X platforms.

In the eyes of programmers, Sublime Text is also a very useful code editor, which supports running programs written in C/C++, Python, Java and other languages.

So far, Sublime Text has iterated 4 versions. In this section, we focus on the Windows platform and explain how to run Python programs on Sublime Text 4.

Install Sublime Text

Open the Sublime Text official website, click "Download" to enter the download page:



Sublime Text can be installed on different platforms, here we click "Windows" to download the Sublime Text installation package available on the Windows platform:

 

After downloading, you will get the Sublime Text 4 installation package (The name of the installation package we downloaded is sublime_text_build_4126_x64_setup). Double-click this installation package to officially start installing Sublime Text. The whole process is very simple (just click Next all the time), so I won't go into details here.

Install the Python environment

Note that the installed Sublime Text cannot directly run the Python program. You need to manually install the Python operating environment. For the installation method, please refer to "Installing Python on Windows" .

After installing the Python runtime environment, open the Windows command line window and enter py or python (the latter needs to configure the environment variables first). If the version information of Python appears, it proves that the installation is complete:



you can see that the version of Python we installed It is 3.10.4, you can install other versions according to your needs.

Sublime Text runs Python programs

After installing Sublime Text and the Python runtime environment, you can write and run Python programs in Sublime Text.

As a simple example, create a demo.py file on Sublime Text and write a Python program in the file:



find "Tools -> Build System" in the menu bar, and then select "Python". Then press the "Ctrl+B" key combination or select the "Build" option in the Tools menu to run the Python program. The result of running the Python program is:



Note that some readers may need to use a different version of Python in Sublime Text, such as Python 2.x and Python 3.x. In this case, we need to configure the Python runtime environment for Sublime Text by ourselves.

In the picture above, Sulime Text uses Python 3.10 to run the Python program. Next, take the manual configuration of the Python 2.7 version as an example to explain the configuration process.
1) Download and install Python 2.7 from the Python official website.

2) Select "Tools -> Build System -> New Build System..." in the menu bar of Sublime Text, Sublime Text will create a file with the suffix .sublime-build:



3) Copy the original file in the configuration file Delete any content and replace it with the following:
{
    "cmd": ["D:\\Python27\\python.exe","-u","$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
}
Note: D:\\Python27\\python.exe is the storage path for installing Python 2.7 on our computer. Readers should modify it to the storage path on their own computer.

After the modification is complete, press "Ctrl+S" to save the configuration file. The save location is the default. The name of the configuration file can be set to "py27.sublime-build".

4) In the Sublime Text menu bar, select "Tools -> Build System -> py27" to run Python programs that conform to the Python 2.7 version. For example,



in the same way, readers can configure various Python versions for Sublime Text operating environment.