2

I can't seem to get Python3 linting working in Visual Studio Code (1.20.1).

I'm using a Homebrew installed version of Python 3.6 and updated all the settings correctly (I think). But I'm not seeing anything to indicate when there's an error (I've purposely just tried typing gibberish, etc). Here's my settings:

{
    "python.pythonPath": "/usr/local/bin/python3",
    "files.autoSave": "afterDelay",
    "python.linting.enabled": true,
    "python.linting.pep8Enabled": true
}

Thanks!

martin
  • 119
  • 6

1 Answers1

1

Enabling python linting in Visual Studio Code will not help by itself, additionally you have to install pep8 itself. You can check for this by typing which pep8, and if it comes back empty, do pip install pep8.

If the extension can't find the installed copy of pep8 for some reason, you can provide the path which points to the pep8, as described in the documentation

That would be "python.linting.pep8Path": "<your-pep8-path>"

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
lesz3k
  • 148
  • 9
  • Ok, that solves part of it. I had already installed pep8, but adding the absolute path worked (even though using "pep8" works in terminal). Still not sure how to get it to highlight code errors (undefined variables, etc). Also, do you know if the colors can be changed? Red for "line too long" seems wrong. – martin Mar 06 '18 at 20:12
  • Have a look into those settings: `"python.linting.pep8CategorySeverity.E": "Error",` `"python.linting.pep8CategorySeverity.W": "Warning",` they basically set the severity of the styling based on the code in your pep8.rc configuration file. make sure that they are defined as above. also, I would make sure that in each of your modules you got the `__init__.py` file, otherwise the linter might not pick up files to scan against. – lesz3k Mar 06 '18 at 20:23
  • Thanks, any idea about the code errors (undefined variables, etc)? – martin Mar 06 '18 at 20:56
  • sure, you define them exactly in the `pep8.rc` file. have a look into this thread how to do it: https://stackoverflow.com/questions/30304409/how-to-write-a-pep8-configuration-pep8-rc-file also, if my answer helped you, please give it a tick :) – lesz3k Mar 07 '18 at 10:36