2

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.

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
KFunk
  • 2,956
  • 22
  • 33

1 Answers1

2

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.

cel
  • 30,017
  • 18
  • 97
  • 117
  • i'm facing the same problem, but i'm not too sure what do you mean by "Update setuptools", can you be a little more specific? – Roberto Aguilar Mar 05 '15 at 07:39
  • 1
    @RobertoAguilar, that depends. This bug is fixed in newer versions of `anaconda`. If you are using `anaconda`, you can just type `conda update flake8`. If you are using vanilla python, you would go with `pip install --upgrade setuptools`, then `pip install --upgrade flake8` – cel Mar 05 '15 at 07:44
  • 1
    I have tried the pip commands and now flake8 is calling pyflakes successfully, thank you very much – Roberto Aguilar Mar 05 '15 at 08:05