SublimeLinter-flake8: Recent update breaks the plugin

The latest update breaks sublimelinter-flake8. To confirm the update is the problem I reverted back to the v2.1.0 where everything works fine.

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/bin/flake8 
SublimeLinter: find_python: <= ('/usr/bin/python', '/usr/bin/flake8', 2, 7) 
SublimeLinter: flake8 version query: /usr/bin/python /usr/bin/flake8 --version 
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
  File "/usr/bin/flake8", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3019, in <module>
    @_call_aside
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3003, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 655, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 963, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 849, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'flake8==3.2.1' distribution was not found and is required by the application

Here’s is the output from flake8

mandeep@debian:~$ which flake8
/usr/bin/flake8
mandeep@debian:~$ /usr/bin/flake8 --version
3.2.1 (mccabe: 0.5.3, pycodestyle: 2.2.0, pyflakes: 1.3.0) CPython 3.5.3 on Linux

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 22 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@eblot For a quick and dirty fix, see my answer above.

First open linter.py:

PackageResourceViewer: Open Resource > SublimeLinter-flake8 > linter.py

Next, replace,

cmd = ('flake8@python', '*', '-')

with,

cmd = ('flake8', '*', '-')

and that should do it.

I’m also seeing this behaviour. In my case I get,

SublimeLinter: find_python(version=None, script='flake8', module=None) 
SublimeLinter: find_python: default python = /usr/bin/python 
SublimeLinter: find_python: available version = {'major': 2, 'minor': 7} 
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

My crude workaround is to replace,

cmd = ('flake8@python', '*', '-')

with,

cmd = ('flake8', '*', '-')

in linter.py. Then SublimeLinter-flake8 uses the correct version of Python (python3 in my case, since I installed flake8 with pip3).

This issue affects me also.

I decided to use the git clone technique to install the old version.

  1. Using Package Control, remove the SublimeLinter-flake8 package.
  2. In the SublimeText app data directory (look here), in Packages/: git clone https://github.com/SublimeLinter/SublimeLinter-flake8 -b 2.1.0.

@asfaltboy you are correct, the default Python in /usr/bin/python is indeed 2.7, and is the macOS provided Python, which I do not use at all (per se).

And there is nothing in /usr/local/bin/python. Only python3 exists. You may have pointed me to right direction, I will try to symlink a bit later.

And last, but not least, thank you very much for your support!

EDIT: I made a symlink as follows: ln -s /usr/local/bin/python3 /usr/local/bin/pythonand hey presto, linter is back alive! Just trying to test, did something else break 😉