如何讓Sublime Text編譯Python?

Yanwei Liu
3 min readJun 29, 2021

--

1.安裝Anaconda

記得勾選Add Anaconda to my PATH environment variable

2. 安裝Sublime Text

3. 開啟Sublime Text

3.1 Tools > Build System > New Build System,將以下程式碼貼上

{
"shell_cmd": "python -u \"$file\"",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},"variants":
[
{
"name": "Syntax Check",
"shell_cmd": "python -m py_compile \"${file}\"",
}
]
}

3.2 使用Ctrl+S存檔,檔名python.sublime-build
3.3 Tools > Build With,名稱選擇3.2取名的「python」(大小寫須符合)
3.4 撰寫Python程式,Ctrl+S存檔(檔名:hello.py),Ctrl+B進行編譯

print('hello world')

4. inconsistent use of tabs and spaces in indentation

view -> indentation -> covert indentation to spaces

參考資料

--

--

No responses yet