sublime_text3執行Python程序環境配置

  用sublime寫了python3的代碼,ctrl + B運行時卻調用了python2,致使運行報錯。
這是由於不少系統默認安裝了python2,默認調用python的版本就是python2。
python

 解決辦法:

  新建一個sublime build system,以下圖1:

圖1

  而後會自動打開了一個文本,清空並寫入如下內容:
ui

{
    "env": {"PYTHONIOENCODING": "utf8"},
    "cmd": ["C:/Users/Administrator/AppData/Local/Programs/Python/Python36/python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}
"env": {"PYTHONIOENCODING": "utf8"}  ##是爲了不中文錯誤
["C:/Users/Administrator/AppData/Local/Programs/Python/Python36/python", "-u","$file"]  ##這裏路徑要替換成你電腦中python3的路徑

  而後,保存文件名爲python3.sublime-build.接着,選擇python3,如圖2所示:

2.png

  配置完成,能夠驗證一下。

3.png

---
  若是出現以下報錯:

  can't find 'main' module in ' '

  緣由是未保存文件,ctrl+s保存一下再次經過ctrl+B執行便可。code

相關文章
相關標籤/搜索