Is it possible to change the python version used by syntastic for syntax checking?
As the Issue https://github.com/scrooloose/syntastic/issues/385 indicates I could use virtual-env. But is it also possible just with syntastic or vim commands?
Is it possible to change the python version used by syntastic for syntax checking?
As the Issue https://github.com/scrooloose/syntastic/issues/385 indicates I could use virtual-env. But is it also possible just with syntastic or vim commands?
In spite of all the answers here, I still find the recommendation from the FAQ to be the best. I have added this to my
.vimrc
so that I can easily switch between python versions.With those functions installed, it's easy to switch python version right within vim with
:call Py2()
or:call Py3()
depending on what I need at the moment. No need to exit vim and activate a different virtualenv as the popular answer would have you do.The below is no longer necessary, and might screw up if you're forced to work on a strictly python 2.x script.
The best option is to leave the Syntastic defaults alone, and to use conda to manage separate environments for python 3 and 2 (each with their own version-specific installs of flake8, pyflakes, etc), and to switch to the appropriate environment to edit each file. Syntastic will then call python/flake8/whatever else according to the paths set in the activated environment.
From the Syntastic repository README:Add that line to your .vimrc - that should fix your problem.I managed to convince Syntastic to handle Python 3 syntax with
(to make
python3 -m flake8 *.py
work) and then, in vim:If you working under virtualenv, you can use a script that detects current python version and invokes
flake8
accordingly. Put the following somewhere in your path and name isflake8.sh
:Now in you
vimrc
add:Also make sure that both
python-flake8
andpython3-flake8
(on Ubuntu) are installed.Not really, but you can get the
python3
incompatible warning by install this package.Let's say your current Syntastic Python checker is
python
and you want to getpython3
incompatible warning. In command mode, you can addpy3kwarn
tog:syntastic_python_checkers
byand switch to
python2.x
onlyConsidering that this question is the first result that appears when searching Google for "Syntastic python3", I have the impression that most answers are too complicated for someone in a hurry, and I feel compelled to add a new one. The straightforward solution to switch to python3 is to put
in your
.vimrc
. One might argue that this is not the best solution, but the question is so vague that is seems necessary to begin with simple things.