sublime text 3 运行python3

设置运行python3

sublime默认的是python2.7如果我想让他运行python3,怎么办呢?

  1. 运行which命令找到python3的路径
which python3

  1. 自定义环境:Tools->Build System->New Build System,会弹出一个后缀为sublime-build的文件。

sublime text 3 运行python3_第1张图片

  • ubuntu/deepin粘贴如下配置,如果发现pyqt5运行的时候啥也不显示,可将"shell":"true"删掉
{
    "cmd": ["/usr/bin/python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell":"true"
}
  • windows粘贴下面的:
{
	"cmd":["E:\\Python\\Python36-32\\python.exe","-u","$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
	"encoding": "utf-8" ,
	"env": {"PYTHONIOENCODING": "utf8"},
	"shell":"true"
}
  • mac粘贴下面的:
{
    "cmd": ["/usr/local/bin/python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
}

记住,其中的python3运行路径要和你系统中的路径一致,然后按Ctlr+S保存文件,文件名改为为python3.sublime-build保存的路径就是Crtl+S后默认的路径,然后你在Tools->Build System,可以看到python3了,选择它再运行python,就会使用python3而不是python2.7了

你可能感兴趣的:(sublime,text,3)