I am using elpy for my Python development, but I would like to set the per-line character limit to 120 instead of the default 80 used by PEP8. Any suggestions on how I can do this? Even better, it would be great if I can customize this setting on a per-project basis.

I have tried the following:

  • M-x customize-group elpy
  • M-x customize-mode elpy-mode
  • M-x customize-mode python-mode

but I can't seem to find the option that customizes the line character limit.

  • I suspect you want fill-column.
    – Dan
    Jun 13, 2016 at 1:13
  • @Dan can you elaborate a bit? I tried setting fill-column (M-x set-fill-column and via M-x customize-variable fill-column), but elpy still shows an error for lines longer than 79 characters, with the message E501 line too long (81 > 79 characters). I tried refreshing the buffer too, but no luck. Any suggestions?
    – modulitos
    Jun 13, 2016 at 3:41
  • This seems like something that needs to be set through the flake8 config file or through the autopep8 config file depending on what you want. Take a look at the configuration page flake8.readthedocs.io/en/latest/config.html
    – Jules
    Jun 13, 2016 at 14:36

1 Answer 1


If you want to customize per project basis, you can create a setup.cfg with custom config like this

max-line-length = 160

If you want to change this globally, you can change flake8 config as mentioned here https://flake8.pycqa.org/en/latest/user/configuration.html#user-configuration

  • Thank you very much! It's exactly what I needed, and now I see that I can use the flake8 config for my elpy-mode. It makes sense, because I believe elpy uses flake8 as the default syntax checker under the hood.
    – modulitos
    Jun 13, 2016 at 19:48
  • 5
    That link is dead - this seems like the current version: https://flake8.readthedocs.io/en/latest/user/configuration.html#user-configuration
    – n1k31t4
    Feb 9, 2018 at 16:16
  • Would someone please tell me how this file is supposed to be created if it doesn't exist? And what's the path?
    – Qohelet
    Mar 24, 2021 at 17:59
  • @Qohelet You can manually create the file and add the required sections to it. By default, it should be in your project root directory. docs.python.org/3/distutils/configfile.html Mar 25, 2021 at 3:47
  • 1
    @ChillarAnand - tried it and it doesn't work, that's how I came here. Emacs still complains
    – Qohelet
    Mar 25, 2021 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.