KFunk
KFunk

Reputation: 3152

Flake8 not using pyflakes in global python instance

My pyflakes portion of flake8 is not running for my global python instance (/usr/bin/python, not virtualenv).

flake8 --version
2.2.3 (pep8: 1.5.7, mccabe: 0.2.1) CPython 2.7.5 on Darwin

It doesn't seem like pyflakes is getting attached to flake8. pip freeze confirms that pyflakes==0.8.1 is installed. I installed on my global site-packages ($ sudo pip install flake8).

However, when running inside of a virtualenv, pyflakes is in the list and flake8 works as expected.

Upvotes: 2

Views: 695

Answers (1)

cel
cel

Reputation: 31339

I had a similar problem with conda's flake8. Here are some debugging notes:

flake8 registers the pyflakes checker in its setup.py file:

setup(
...
    entry_points={
        'distutils.commands': ['flake8 = flake8.main:Flake8Command'],
        'console_scripts': ['flake8 = flake8.main:main'],
        'flake8.extension': [
            'F = flake8._pyflakes:FlakesChecker',
        ],
    },
...

When checking a file, flake8 loads the registered entry points for 'flake8.extension' and registers found checkers:

...
for entry in iter_entry_points('flake8.extension'):
    checker = entry.load()
    pep8.register_check(checker, codes=[entry.name])
...

conda's flake8 seems to have problems writing those entry points.

from pkg_resources import iter_entry_points
list(iter_entry_points('flake8.extension'))

returns an empty list for me, which is why pyflakes won't be registered and thus does not work, even though it is installed and importable.

Updating setuptools and installing via pip install flake8 fixes the problem for me.

Upvotes: 2

Related Questions