sublimelinter - pyflakes Python 默认版本的问题

2017-10-27 10:54:49 +08:00
 nightstart

平时用的 sublime + sublimelinter + sublimelinter-pyflakes 来进行代码的格式检测 但是突然发现 python 的新语法 f"hello {name}" 会被检查出 syntax error 打开调试界面看了一下发现了这么一段

SublimeLinter: find_python(version=None, script='flake8', module=None) 
SublimeLinter: find_python: default python = /usr/bin/python 
SublimeLinter: find_python: available version = {'minor': 7, 'major': 2} 
SublimeLinter: find_python: 'flake8' path = /usr/local/bin/flake8 
SublimeLinter: find_python: <= ('/usr/bin/python', '/usr/local/bin/flake8', 2, 7) 
SublimeLinter: flake8 version query: /usr/bin/python /usr/local/bin/flake8 --version 

虽然上面这个是 flake8 但请大家不要介意 这个 find_python default python = /usr/bin/python 让我很不解

因为我在 sublimelinter 的配置文件里面都已经设置了 @python3: "3.6"

具体内容如下

SublimeLinter: find_posix_python: python3 => /usr/local/python3.6/bin/python3 
SublimeLinter: find_python: system python = /usr/local/python3.6/bin/python3 
SublimeLinter: find_python: available version = {'minor': 6, 'major': 3} 
SublimeLinter: find_python: <= ('/usr/local/python3.6/bin/python3', None, 3, 6) 
SublimeLinter: sys.path for /usr/local/python3.6/bin/python3:
/usr/local/python3.6/lib/python36.zip
/usr/local/python3.6/lib/python3.6
/usr/local/python3.6/lib/python3.6/lib-dynload
/usr/local/python3.6/lib/python3.6/site-packages
 
SublimeLinter: pyflakes imported <module 'pyflakes.api' from '/usr/local/python3.6/lib/python3.6/site-packages/pyflakes/api.py'> 
SublimeLinter: pep8 imported <module 'pep8' from '/usr/local/python3.6/lib/python3.6/site-packages/pep8.py'> 
SublimeLinter: pyflakes version: 1.6.0 
SublimeLinter: pyflakes: (>= 0.7.3) satisfied by 1.6.0 
SublimeLinter: pyflakes activated: <builtin> 
SublimeLinter: pep8 version: 1.7.0 
SublimeLinter: pep8: (>= 1.4.6) satisfied by 1.7.0 
SublimeLinter: pep8 activated: <builtin> 
SublimeLinter: mypy version query: /usr/local/python3.6/bin/mypy --version 
SublimeLinter: mypy version: 0.540 
SublimeLinter: mypy: (>= 0.520) satisfied by 0.540 
SublimeLinter: mypy activated: /usr/local/python3.6/bin/mypy (disabled in settings) 
SublimeLinter: find_python(version=None, script='flake8', module=None) 
SublimeLinter: find_python: default python = /usr/bin/python 
SublimeLinter: find_python: available version = {'minor': 7, 'major': 2} 
SublimeLinter: find_python: 'flake8' path = /usr/local/bin/flake8 
SublimeLinter: find_python: <= ('/usr/bin/python', '/usr/local/bin/flake8', 2, 7) 
SublimeLinter: flake8 version query: /usr/bin/python /usr/local/bin/flake8 --version 
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 7, in <module>
    from flake8.main.cli import main
ImportError: No module named flake8.main.cli

希望对这个有研究的 V 友能帮忙看一下 感激不尽

3213 次点击
所在节点    Python
3 条回复
nightstart
2017-10-27 12:24:37 +08:00
顶自己一下
smallzhan
2017-10-27 13:09:05 +08:00
@nightstart 检查下 flake8 脚本的第一行。估计指向了错误的 python 版本。
nightstart
2017-10-27 13:22:56 +08:00
@smallzhan 我找到问题了 python 指向是正确的 sublimelinter 设置也是正确的 亏在了缓存文件上。 我把缓存文件删了就正常了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/401143

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX