sublimetextpython代码提⽰_SublimeText3配置python开发
环。。。
安装的主要插件:
SublimeTmpl 提供了常⽤⽂件模板,新建⽂件时很有⽤。
Anaconda 是⼀个终极 Python 插件。它为 ST3 增添了多项 IDE 类似的功能,例如:
Autocompletion ⾃动完成,该选项默认开启,同时提供多种配置选项
Goto Definitions 能够在你的整个⼯程中查并且显⽰任意⼀个变量,函数,或者类的定义。
Find Usage 能够快速的查某个变量,函数或者类在某个特定⽂件中的什么地⽅被使⽤了
Code linting 代码静态分析功能,包括格式等,检查使⽤⽀持 pep8 标准的 PyLint 或者 PyFlakes
SublimeLinter 会帮你查代码是否符合PEP8的要求。有问题有代码会出现⽩框,点击时底下的状态栏会提⽰出什么问题。
Python PEP8 Autoformat 使⽤它进⾏符合PEP8要求的格式化
SublimeREPL REPL就是read-evaluation-print-loop,(解释型语⾔编译运⾏的过程)。装了SublimeREPL插件后也⽀持了编辑器上直接的编译运⾏和交互
我配置过程中遇见的问题和解决⽅法:
Anaconda的问题
Anaconda默认配置和详细说明
Anaconda配置⽂件在
Sublime > Preferences > Package Settings > Anaconda > Settings – User:
{ "pep8_ignore":
[
"E501",
],
"complete_parameters": true,
"anaconda_linting_behaviour": "save-only",// always
"anaconda_gutter_theme": "hard",
"anaconda_linter_show_errors_on_save": true,
"python_interpreter": "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3",
"anaconda_linting": true,
}
a. 代码linting太严
例如:我逗号”,”后⾯没加空格,它就会⽤⽩框框这么提⽰我代码不规范
它管的太严,所以我们可以在pep8_ignore⾥填⼊要忽视的错误码,所有错误码
E101 - Reindent all lines.
E111 - Reindent all lines.
E121 - Fix indentation to be a multiple of four.
E122 - Add absent indentation for hanging indentation.
E123 - Align closing bracket to match opening bracket.
E124 - Align closing bracket to match visual indentation. E125 - Indent to distinguish line from next logical line.
E126 - Fix over-indented hanging indentation.
E127 - Fix visual indentation.
E128 - Fix visual indentation.
E129 - Indent to distinguish line from next logical line.
E201 - Remove extraneous whitespace.
E202 - Remove extraneous whitespace.
E203 - Remove extraneous whitespace.
E211 - Remove extraneous whitespace.sublime text3安装教程
E221 - Fix extraneous whitespace around keywords.
E222 - Fix extraneous whitespace around keywords.
E223 - Fix extraneous whitespace around keywords.
E224 - Remove extraneous whitespace around operator. E225 - Fix missing whitespace around operator.
E226 - Fix missing whitespace around operator.
E227 - Fix missing whitespace around operator.
E228 - Fix missing whitespace around operator.
E231 - Add missing whitespace.
E241 - Fix extraneous whitespace around keywords.
E242 - Remove extraneous whitespace around operator. E251 - Remove whitespace around parameter ‘=’ sign. E261 - Fix spacing after comment hash.
E262 - Fix spacing after comment hash.
E271 - Fix extraneous whitespace around keywords.
E272 - Fix extraneous whitespace around keywords.
E273 - Fix extraneous whitespace around keywords.
E274 - Fix extraneous whitespace around keywords.
E301 - Add missing blank line.
E302 - Add missing 2 blank lines.
E303 - Remove extra blank lines.
E304 - Remove blank line following function decorator.
E401 - Put imports on separate lines.
E501 - Try to make lines fit within –max-line-length characters.
E502 - Remove extraneous escape of newline.
E701 - Put colon-separated compound statement on separate lines.
E702 - Put semicolon-separated compound statement on separate lines.
E703 - Put semicolon-separated compound statement on separate lines.
E711 - Fix comparison with None.
E712 - Fix comparison with boolean.
W191 - Reindent all lines.
W291 - Remove trailing whitespace.
W293 - Remove trailing whitespace on blank line.
W391 - Remove trailing blank lines.
E26 - Format block comments.
W6 - Fix various deprecated code (via lib2to3).
W602 - Fix deprecated form of raising exception.
或者我们可以关闭anaconda的代码检查”anaconda_linting”: false,
使⽤Python PEP8 Autoformat 格式化代码
b. anaconda 不能⾃动补全第三⽅库
原因是:Anaconda使⽤的Python版本不是我们系统安装的Python
可通过⼀下进⾏配置,使anaconda使⽤我们电脑上的Python,那样安装在我们电脑上python的第三⽅库也就会⾃动导⼊了
官⽅配置传送门
如上,关键在”python_interpreter”中写⼊本机安装的python的完整路径,例
如:/Library/Frameworks/Python.framework/Versions/3.5/bin/python3,
SublimeREPL的问题
使⽤SublimeREPL进⾏编译运⾏时,设置SublimeREPL的python为我们机器上的python,不然会出现和上⾯Anaconda的b⼀样的问题解决⽅法:从电脑⽬录⾥到SublimeREPL/config/Python/Main.sublime-menu⽂件
例如:Packages/User/SublimeREPL/config/Python/Main.sublime-menu
在Main.sublime-menu⽂件⾥配置如下:
我最常⽤的是⽤python或者run current file,所以到这两个,在他们的cmd下填⼊要关联的本机的python所在的完整⽬录{"command": "repl_open",
"caption": "Python",
"id": "repl_python",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.5/bin/python3", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Language",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
{"command": "repl_open",
"caption": "Python - RUN current file",
"id": "repl_python_run",
"mnemonic": "R",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.5/bin/python3", "-u", "$file_basename"], "cwd": "$file_path",
"syntax": "Packages/Language",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
that’s all ! thank you !
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论