V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
nightstart
V2EX  ›  Python

sublimelinter - pyflakes Python 默认版本的问题

  •  
  •   nightstart · 2017-10-27 10:54:49 +08:00 · 3177 次点击
    这是一个创建于 2583 天前的主题,其中的信息可能已经有所发展或是发生改变。

    平时用的 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 友能帮忙看一下 感激不尽

    3 条回复    2017-10-27 13:22:56 +08:00
    nightstart
        1
    nightstart  
    OP
       2017-10-27 12:24:37 +08:00
    顶自己一下
    smallzhan
        2
    smallzhan  
       2017-10-27 13:09:05 +08:00   ❤️ 1
    @nightstart 检查下 flake8 脚本的第一行。估计指向了错误的 python 版本。
    nightstart
        3
    nightstart  
    OP
       2017-10-27 13:22:56 +08:00
    @smallzhan 我找到问题了 python 指向是正确的 sublimelinter 设置也是正确的 亏在了缓存文件上。 我把缓存文件删了就正常了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5803 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:18 · PVG 14:18 · LAX 22:18 · JFK 01:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.