Home Development Tools sublime Simple tutorial for configuring Python interpreter in Sublime Text editor

Simple tutorial for configuring Python interpreter in Sublime Text editor

Oct 21, 2019 am 11:56 AM
sublime text

The day before yesterday, I met a friend on WeChat who asked me a question about configuring the Python interpreter for Sublime text. He may be a beginner and doesn’t know much about this aspect. He wanted to use shortcut keys but it was in vain because he lacked Python. Interpreter, pressing the shortcut key Ctrl B directly will not get the desired result.

In view of this, if anyone wants to use Sublime to run Python programs, then configuring the Python interpreter is an essential step. Here, the editor has compiled this step-by-step tutorial, hoping to pave the way for newcomers.

Simple tutorial for configuring Python interpreter in Sublime Text editor

The following tutorial column will introduce to you how to configure the Python interpreter in the Sublime Text editor: 1. First open Sublime, as shown in the figure below, and then select the "Preferences" tab. 2. Click the first option "Browse Packages...", and then the system will automatically locate the Sublime installation package directory.

3. Then the folder interface as shown below will pop up.

4. Find the Python folder in this pile of folders, as shown in the figure below, then enter the folder and find the Python.sublime-build file.

5. Open the file in Sublime, as shown in the figure below.

{
"cmd":["python.exe","-u", "$file"],
"path":"C:\Python34",
"file_regex": "^[ ]File"(...?)", line ([0-9]*)",
"encoding": "gbk",
"selector": "source.python"
}
Copy after login

The content shown in the picture is the content after I updated it. The original content is not so rich. Mainly to change two places, one is to add the Python interpreter path, and the second is to add the encoding part. Generally, the encoding chosen is utf-8 or gbk, and some use cp936, mainly to prevent Sublime Text from reporting [Decode error - output not utf-8] error. Generally speaking, if we do not set the encoding, once the output is in a language other than English, encoding problems will occur, which is a headache. Generally, it is not a big problem if you try several encodings.

6. After changing the Python.sublime-build file, press the shortcut key Ctrl S to save it. Then open a Python file at will, and then click the tab ToolsàBuildSystemàPython in Sublime, as shown in the figure below. The whole process is equivalent to completing the perfect "connection" between Sublime and the Python interpreter.

7. Now you can use the shortcut key Ctrl B or add the tab ToolsàBuild in sequence, as shown in the figure below, and then you can run the current Python file. The effect is as shown in the figure below. The output part of the file is below Sublime, usually a gray rectangular part.

8. At this point, the problem of configuring the Python interpreter in Sublime and the [Decode error - output not utf-8] error has been successfully solved.

I hope that when future friends encounter this problem again, they can avoid detours. Although the editor is currently using Sublime Text 2, the configuration method of Sublime Text 3 is exactly the same as Sublime Text 2, so I won’t go into details.

The above is the detailed content of Simple tutorial for configuring Python interpreter in Sublime Text editor. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Let's talk about how to turn off automatic updates in Sublime (picture and text introduction) Let's talk about how to turn off automatic updates in Sublime (picture and text introduction) Feb 24, 2022 am 10:29 AM

Below, the sublime tutorial column will introduce to you how to turn off automatic updates in Sublime Text. I hope it will be helpful to friends in need!

Development tools and debugging skills for PHP and CGI: improving development efficiency Development tools and debugging skills for PHP and CGI: improving development efficiency Jul 21, 2023 pm 03:12 PM

Development tools and debugging skills for PHP and CGI: Improving development efficiency Summary: PHP and CGI are two commonly used web development languages. In order to improve development efficiency, developers need to master some special development tools and debugging skills. This article will introduce several commonly used PHP and CGI development tools, as well as some debugging techniques to help developers develop and debug more efficiently. 1. Development tool SublimeTextSublimeText is a powerful text editor that supports PHP and C

A brief analysis of the reasons and solutions for why sublime text cannot run php A brief analysis of the reasons and solutions for why sublime text cannot run php Mar 24, 2023 am 10:58 AM

SublimeText is a very popular code editor that is widely used by developers and code writers. In the following article, we will discuss the reasons and solutions for why SublimeText cannot run PHP.

What are the common code editors for PHP programming? What are the common code editors for PHP programming? Jun 12, 2023 pm 12:30 PM

PHP is a popular server-side scripting language that is widely used for web development. In order to write efficient and streamlined PHP code, programmers need to use an excellent code editor. This article will introduce some common code editors in PHP programming. SublimeTextSublimeText is probably one of the most popular code editors. Its flexibility and ease of use make it the editor of choice for many developers. Key features of SublimeText include: High degree of customization

Recommended configuration for C/C++ programming using Sublime Text on Linux Recommended configuration for C/C++ programming using Sublime Text on Linux Jul 04, 2023 pm 05:57 PM

Introduction to the recommended configuration for using SublimeText for C/C++ programming on Linux: SublimeText is a lightweight, powerful and highly customizable text editor. On Linux platforms, using SublimeText for C/C++ programming is a common choice. This article will introduce some recommended configurations and plug-ins to help improve programming efficiency and development experience. Install SublimeText: First, you need to install SublimeText from the SublimeText official website

Common PHP editors and development tools Common PHP editors and development tools Jun 23, 2023 am 09:36 AM

In current web development, PHP has become a very popular back-end programming language. However, when developing PHP, choosing high-quality editors and development tools can greatly improve development efficiency and code quality. This article will introduce some common PHP editors and development tools. PHPStormPHPStorm is an integrated development environment (IDE) launched by JetBrains. It provides a series of functions such as powerful PHP development support, code analysis, debugging, and automated testing, and supports

How to build php in sublime How to build php in sublime Oct 26, 2022 am 09:31 AM

How to build PHP with sublime: 1. Open sublime, click "Ctrl+Shift+P", and then enter install; 2. Configure SublimeLinter; 3. Modify the path; 4. Configure the PHP compilation system; 5. Add "{ "cmd": ["php","$file"],"file_regex": "php$","selector":"source.php"}" is enough.

Sublime Text function for PHP function Sublime Text function for PHP function Mar 27, 2024 am 08:42 AM

PHP is a popular programming language that is widely used to create dynamic websites, applications, and a range of internet technologies. PHP has a large number of built-in functions to help programmers work more efficiently while writing code. If you use SublimeText as your editor, there are some plugins and tricks you can use to make your PHP functions easier to edit and use. In this article, I will introduce some useful SublimeText features that can help you make better use of PHP functions. 1.from

See all articles