15

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...

wasabigeek
  • 2,923
  • 1
  • 21
  • 30
batatop
  • 979
  • 2
  • 14
  • 31
  • "Bash on Windows" a.k.a WSL is a command line environment. What is the point of using a GUI editor (VS Code) in it? Anyway, paths to folders shared by host Windows and the "bash" container begin with /mnt/c (or other drive letter), yes you need to use different paths on Windows and bash sides. RTFM. – ddbug Oct 05 '17 at 20:26
  • @ddbug Thank for your comment. VS Code is a code editor for any programming language. I'm using the bash to compile the code through the editor. However, the linter is already installed in the bash. Therefore I don't need /mnt/c to access my documents in Windows. I tried "C:\\Users\\user\\AppData\\Local\\lxss\rootfs\\usr\bin\\pylint" but that didn't work too. – batatop Oct 05 '17 at 20:46

3 Answers3

4

From what I can tell, if you're using WSL, the shell is a separate environment from VSCode. That's why the git extension won't work unless you install the Windows version, even if you've installed it in WSL. And while it is possible to invoke WSL from Windows, I've not been able to get it working.

So for linting, install Python and flake8 in Windows (e.g. pip install flake8 in Git Bash) and you should be fine.

P.S. If someone can tell me otherwise, I'd love to know! It's a bit annoying having to essentially download stuff twice (once in Windows, once in WSL).

wasabigeek
  • 2,923
  • 1
  • 21
  • 30
2

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.

Sam Bradley
  • 56
  • 1
  • 5
1

Visual Studio Code just released a tutorial to properly run the application with WSL.

Remote development in WSL

batatop
  • 979
  • 2
  • 14
  • 31
  • Also I'm not currently writing in Python, so I haven't tested if it solves the problem. I wanted to share it since it is just released. – batatop Aug 16 '19 at 02:21