Switch Python Version for Vim & Syntastic

2019-02-07 23:51发布

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?

8条回答
【Aperson】
2楼-- · 2019-02-08 00:34

Just to iterate on Zaar Hai's script a bit, something like this should work and be a bit more robust.

#!/usr/bin/env bash

_python=$(command -v python)

[[ "$(uname -s)" =~ Darwin ]] && IS_OSX=true

if [[ "$IS_OSX" ]]; then
    if command -v 'greadlink' >/dev/null 2>&1; then
        greadlink -f "$_python"
    else
        echo 'Install coreutils!' >&2
    fi
else
    readlink -f "$_python"
fi
查看更多
戒情不戒烟
3楼-- · 2019-02-08 00:41

Only I did to fix this was to do:

  let g:syntastic_python_flake8_exec = '/path/to/python3'

To make sure flake8 is synced with Python3's syntax. Even when I'm in a virtualenv works.

查看更多
登录 后发表回答