0

I am using emacs on Ubuntu 16.04 and added the configuration for flycheck-mode to include the python3 setup below:

Emacs: How do I set flycheck to Python 3?

Answer: https://stackoverflow.com/a/55000284/719016

(custom-set-variables
 '(flycheck-python-flake8-executable "python3")
 '(flycheck-python-pycompile-executable "python3")
 '(flycheck-python-pylint-executable "python3"))

But my python3 buffer still gives me an invalid syntax [E0001] error in a line like below:

print("# My message for the stderr", file=stderr)

The syntax checkers loaded are python-pylint and python-pycompile (for some reason python-flake8 does not seem to be found.

Any ideas why?

nega
  • 2,526
  • 20
  • 25
719016
  • 9,922
  • 20
  • 85
  • 158

1 Answers1

1

Well, if you took the answer that you quoted literally, your configuration isn't getting loaded. The answer suggests putting the config in ~/.emacs.c/custom.el. That's a typo. The correct path is ~/.emacs.d/custom.el. The more correct answer is to put the config in the file pointed to by custom-file. The most correct answer is to never edit the custom file by hand. Instead use the customize facility.

  • Run M-x customize-group flycheck.
  • Scroll to the bottom of the buffer and click on "Flycheck executables".
  • Find the python executables you want to change. (Always use python3 for Python3 stuff, even if you only have Python3 on your system. It'll save you headaches later.)
  • Scroll to the top of the buffer.
  • Click "Apply and Save".
  • Boom. Your settings are saved in the correct "custom.el" file.

Now, load up a Python3 file you want to use flycheck with. If it's not doing what you expect, check things with C-c ! v (aka flycheck-verify-setup.) Confirm individual checkers with C-c ! ? (aka flycheck-describe-checker.) Check the variables you think you're setting with C-h v. Cut-n-paste them from flycheck's website if you have to.

Don't worry about flake8's config file. It will properly cascade as you expect.

And, lastly, as @jenesaisquois suggests:

#!/usr/bin/env python3

import sys
print("# My message for the stderr", file=sys.stderr)
nega
  • 2,526
  • 20
  • 25