8

I installed flake8 using the following command.

pip3 install flake8

Executing flake8 from terminal gives the following error.

Traceback (most recent call last):
  File "/home/bilesh/.local/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 394, in run
    self._run(argv)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 381, in _run
    self.initialize(argv)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 365, in initialize
    self.register_plugin_options()
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 206, in register_plugin_options
    self.check_plugins.register_options(self.option_manager)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 496, in register_options
    list(self.manager.map(register_and_enable))
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 302, in map
    yield func(self.plugins[name], *args, **kwargs)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 492, in register_and_enable
    call_register_options(plugin)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 404, in generated_function
    return method(optmanager, *args, **kwargs)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 221, in register_options
    add_options(optmanager)
  File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/_pyflakes.py", line 79, in add_options
    parser.config_options.extend(['builtins', 'doctests',
AttributeError: 'OptionManager' object has no attribute 'config_options'

Found the following bug from 2016 but it seems to have been fixed.

https://github.com/PyCQA/flake8-import-order/issues/79

Not sure if I'm doing anything wrong here. Any help will be appreciated.

$ pip3 freeze | grep flake8
flake8==3.7.7
flake8-docstrings==1.3.0
flake8-polyfill==1.0.2
Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
  • 1
    After `pip install flake8==3.7.7 flake8-docstrings==1.3.0 flake8-polyfill==1.0.2` my `flake8/` directory doesn't contain `_pyflakes.py`. Try to uninstall `flake8`, clean the directories and reinstall. – phd Mar 30 '19 at 14:17
  • @phd - Thanks! I tried twice and it worked the second time :) – Bilesh Ganguly Mar 30 '19 at 23:13

1 Answers1

8

So, as per the comment posted by phd on this question, I did the following things.

  1. Uninstall flake8: pip3 uninstall flake8
  2. Clean directories: sudo rm -R /path/to/directory/flake8
  3. Reinstall flake8: pip3 install flake8

And it worked :)

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58