这个一般是跟sublime编辑器引入的本地python程序版本有关,当前版本超过了编辑器内定版本,我当前编辑器是上面写了34版本,本地安装的都是37版本了。
解决办法:
打开这个路径:
E:\sublime text 3\Data\Packages\Anaconda\anaconda_lib\linting\pyflakes\checker.py
步骤一:找到这几行代码(70行左右):
if PY34_PLUS:
FOR_TYPES = (ast.For, ast.AsyncFor)
LOOP_TYPES = (ast.While, ast.For, ast.AsyncFor)
else:
FOR_TYPES = (ast.For,)
LOOP_TYPES = (ast.While, ast.For)
替换成下面的代码:
if PY2:
LOOP_TYPES = (ast.While, ast.For, ast.AsyncFor)
else:
LOOP_TYPES = (ast.While, ast.For)
步骤二:找到这几行代码(20行左右)
PY2 = sys.version_info < (3, 0)
PY35_PLUS = sys.version_info >= (3, 5) # Python 3.5 and above
PY36_PLUS = sys.version_info >= (3, 6) # Python 3.6 and above
PY38_PLUS = sys.version_info >= (3, 8)
在中间加上37的配置代码,改为
PY2 = sys.version_info < (3, 0)
PY35_PLUS = sys.version_info >= (3, 5) # Python 3.5 and above
PY36_PLUS = sys.version_info >= (3, 6) # Python 3.6 and above
PY37_PLUS = sys.version_info >= (3, 7)
PY38_PLUS = sys.version_info >= (3, 8)
重启sublime编辑器就行了