15

我在 64 位 PC 上使用 Windows 10。最近,我开始在 Windows 上使用 VS Code 和 Ubuntu Bash。除了掉毛,一切都很好。我试图让它与 pylint 和 pep8 一起工作,但它们都不起作用。我认为问题是由于 linter 的位置引起的。但是,我不知道如何解决这个问题。您可以检查我的 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": [],

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

4

3 回答 3

4

据我所知,如果您使用的是 WSL,那么 shell 是与 VSCode 分开的环境。这就是为什么除非你安装 Windows 版本,否则 git 扩展将无法工作,即使你已经在 WSL 中安装了它。虽然可以从 Windows 调用 WSL,但我无法让它工作。

因此,对于 linting,在 Windows 中安装 Python 和 flake8(例如,在 Git Bash 中安装 pip install flake8)就可以了。

PS如果有人可以告诉我,我很想知道!必须两次下载东西(一次在 Windows 中,一次在 WSL 中),这有点烦人。

于 2017-10-13T08:30:52.830 回答
2

切换回 windows 后,我自己一直在努力解决这个问题,我发现了这个: https ://github.com/Microsoft/vscode-python/issues/67

这是涵盖此确切场景的未解决问题,评论中有一些技巧和解决方法,但由于它现在是一个可见且高优先级的问题,真正的解决方案是等待 vs 代码中的修复。

或者,您可以使用本指南在 WSL 环境中安装 VS Code: https ://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows

这将运行 VS 代码的 linux 版本,因此它将使用安装在那里的环境进行 linting。

于 2018-10-06T04:44:06.630 回答
1

Visual Studio Code 刚刚发布了使用 WSL 正确运行应用程序的教程。

WSL 中的远程开发

于 2019-08-16T02:19:16.413 回答