Visual Studio代码,与WSL的Python LINT(用于Linux的Windows子系统)

问题描述:

我在64位PC上使用Windows 10。最近,我开始在Windows上使用VS Bash和Ubuntu Bash。除了掉毛之外,一切都很好。我试图让它与pylint和pep8一起工作,但没有一个能够工作。我认为问题是由于棉绒的位置造成的。但是,我无法弄清楚如何解决这个问题。您可以检查我的设置为pylint:Visual Studio代码,与WSL的Python LINT(用于Linux的Windows子系统)

// 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": [], 

我将不胜感激任何帮助。谢谢你...

+0

“Bash on Windows”a.k.a WSL是一个命令行环境。在其中使用GUI编辑器(VS代码)有什么意义?无论如何,主机Windows和“bash”容器共享的文件夹路径以/ mnt/c(或其他驱动器号)开头,是的,您需要在Windows和bash端使用不同的路径。 RTFM。 – ddbug

+0

@ddbug感谢您的评论。 VS Code是任何编程语言的代码编辑器。我使用bash通过编辑器编译代码。但是,linter已经安装在bash中。因此,我不需要/ mnt/c在Windows中访问我的文档。我尝试过“C:\\ Users \\ user \\ AppData \\ Local \\ lxss \ rootfs \\ usr \ bin \\ pylint”,但这并没有奏效。 –

从我所知道的,如果你使用WSL,shell是一个独立于VSCode的环境。这就是为什么git扩展won't work,除非你安装Windows版本,即使你已经安装在WSL中。虽然有可能invoke WSL from Windows,但我一直无法使它工作。

因此,对于linting,在Windows中安装Python和flake8(例如,在Git Bash中安装flake8),你应该没问题。

P.S.如果有人能告诉我,否则,我很想知道!实际上不得不下载两次东西(一次是在Windows中,一次是在WSL中)。