Search code examples
pythonvisual-studio-codewindows-subsystem-for-linuxbash-on-windows

Visual Studio Code, Python linting with WSL (Windows Subsystem for Linux)


I'm using Windows 10 on 64 bit PC. Recently, I started using VS Code with Ubuntu Bash on Windows. Everything works great except linting. I tried to get it working with pylint and pep8 but none of them worked. I think that the problem is caused because of the location of the linter. However, I couldn't figure out how to fix the problem. You can check my settings for the pylint:

// Whether to lint Python files using pylint.
"python.linting.pylintEnabled": true,

// Severity of Pylint message type 'Convention/C'.
"python.linting.pylintCategorySeverity.convention": "Information",

// Severity of Pylint message type 'Refactor/R'.
"python.linting.pylintCategorySeverity.refactor": "Hint",

// Severity of Pylint message type 'Warning/W'.
"python.linting.pylintCategorySeverity.warning": "Warning",

// Severity of Pylint message type 'Error/E'.
"python.linting.pylintCategorySeverity.error": "Error",

// Severity of Pylint message type 'Fatal/F'.
"python.linting.pylintCategorySeverity.fatal": "Error",

// Path to Pylint, you can use a custom version of pylint by modifying this 
// setting to include the full path.
"python.linting.pylintPath": "pylint",

// Arguments passed in. Each argument is a separate item in the array.
"python.linting.pylintArgs": [],

I would appreciate any help. Thank you...


Solution

  • I've been struggling with this myself after switching back to windows , I found this: https://github.com/Microsoft/vscode-python/issues/67

    Which is the open issue that covers this exact scenario, there are a couple hacks and work arounds in the comments but as it is now a visible and high priority issue the real solution is to wait for a fix in vs code.

    Alternatively you can install VS Code in the WSL environment using this guide: https://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows

    This would be running the linux version of VS code so it would be linting using the environments installed there.