Search code examples
pythonpython-3.xpipflake8

Running flake8 gives - AttributeError: 'OptionManager' object has no attribute 'config_options'


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

Solution

  • 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 :)