代码之家  ›  专栏  ›  技术社区  ›  batatop

Visual Studio代码,Python linting with WSL(Linux的Windows子系统)

  •  15
  • batatop  · 技术社区  · 9 年前

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

    如果有任何帮助,我将不胜感激。非常感谢。

    3 回复  |  直到 8 年前
        1
  •  4
  •   wasabigeek    9 年前

    据我所知,如果您使用的是WSL,那么shell是与VSCode分离的环境。这就是git扩展的原因 won't work 除非您安装Windows版本,即使您已经在WSL中安装了它。虽然有可能 invoke WSL from Windows ,我一直无法让它工作。

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

    P、 如果有人能告诉我其他的,我很想知道!必须下载两次东西(一次在Windows中,一次在WSL中),这有点烦人。

        2
  •  2
  •   Sam Bradley    8 年前

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

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

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

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

        3
  •  1
  •   batatop    7 年前

    Visual Studio Code刚刚发布了一个教程,用于使用WSL正确运行应用程序。

    Remote development in WSL