美文网首页寒哥管理的技术专题
Ubuntu 16.04下指定Sublime Text 3 默认

Ubuntu 16.04下指定Sublime Text 3 默认

作者: 大老虎小老虎 | 来源:发表于2016-06-19 16:39 被阅读0次

安装PackageResourceViewer插件

1. 输入Ctrl+Shift+P

2. 输入install,选择Package Control: Install Package

3. 选择PackageResourceViewer,安装

设置默认的 Python.sublime-build

1. 输入Ctrl+Shift+P

2. 输入resource,选择PackageResourceViewer:Open Resource

3. 再选择Python,再再选择Python.sublime-build

4. 编辑Python.sublime-build将"shell_cmd": "python -u \"$file\"",改为以下之一:

"shell_cmd": "python3 -u \"$file\"", //指定python3为.py默认编译器

"shell_cmd": "python2 -u \"$file"", //指定python2为.py默认编译器

"shell_cmd": "python -u \"$file\"", //根据Ubuntu系统设置,看/usr/bin/python链接哪儿(ln)

"shell_cmd": "指定版本python的绝对路径 -u \"$file\"", //指定路径下的python编译器

5. 使用python3的配置文件示例(Python.sublime-build)

{

//"shell_cmd":"python -u \"$file\"",

"shell_cmd":"python3 -u \"$file\"",  //指定python3为.py默认编译器

"file_regex":"^[ ]*File \"(...*?)\", line ([0-9]*)",

"selector":"source.python",

"env":{"PYTHONIOENCODING":"utf-8"},

"variants":

[

 {

   "name":"Syntax Check",

   "shell_cmd":"python -m py_compile \"${file}\"",

   }

 ]

}

6. Ctrl+S 保存配置文件

注:有关.sublime-build的配置信息说明,可见参见这儿

7. 重启Sublime Text 3

8. 打开.py文件,Ctrl + B 即可编译执行

呵呵,方便、顺眼多了

与其他方法的使用比较

网上也有其他变通方法,可以参考下面链接:

ubuntu下sublime text 3加入python3环境支持

指定ubuntu下的Python的运行版本

个人感觉:

前者,每次编译时选择麻烦
后者,改系统默认配置,可能引发其他依赖异常

最后,本文方法Ctrl+B直接编译运行,又不改系统默认配置,对我最合适,简单、完美 :-)

相关文章

网友评论

    本文标题:Ubuntu 16.04下指定Sublime Text 3 默认

    本文链接:https://www.haomeiwen.com/subject/oymbdttx.html