如何将Syntastic设置为python3检查器而不是python2 [英] How to setup Syntastic as python3 checker instead of python2
问题描述
在MacVim中,我将以下代码另存为test.py
In MacVim, I save following code as test.py
print "Hello world! python2"
,显然是python3的错误,但是 我运行:w保存文件后,没有错误信息出现, 以下是〜/.vimrc的一部分,全部与Syntastic有关:
, which is apparently wrong with python3, but after I run :w to save the file, there is no error message for it, Following is a part of ~/.vimrc, which is all about Syntastic:
" Syntastic
"" Recommended settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
"" Display checker-name for that error-message
let g:syntastic_aggregate_errors = 1
"" I use the brew to install flake8
let g:syntastic_python_checkers=['flake8', 'python3']
当我在终端中运行test.py时,如何使Syntastic检测此类错误:
How to make Syntastic detect this type of error as I run test.py in Terminal:
NingGW:Desktop ninggw$ python3 test.py
File "test.py", line 1
print "Hello world! python2"
^
SyntaxError: Missing parentheses in call to 'print'
以下是:SyntasticInfo所说的:
Following is what :SyntasticInfo said:
Syntastic version: 3.8.0-10 (Vim 800, Darwin, GUI)
Info for filetype: python
Global mode: active
Filetype python is active
The current file will be checked automatically
Available checkers: flake8 python
Currently enabled checker: flake8
Press ENTER or type command to continue
推荐答案
flake8
是Python软件包.它使用Python的内置功能来解析代码,因此它接受所属的Python版本的语法.
flake8
is a Python package. It uses Python's built-in facilities to parse code, so it accepts syntax for the Python version that it belongs to.
如何为python3
安装安装它取决于安装本身的安装方式-除非您使用pip
很好.
How to install it for your python3
installation depends on how that installation itself was installed - unless you're fine with using pip
.
这篇关于如何将Syntastic设置为python3检查器而不是python2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!