【问题标题】:Pylint not showing ouput in VSCodePylint 未在 VSCode 中显示输出
【发布时间】:2021-06-07 08:49:41
【问题描述】:

我正在尝试检查我正在处理“python_record.py”的脚本中的问题。如果我在终端中运行 pylint python_record.py,我会得到一个带有多个错误的长输出。

但是当我通过 VSCode 运行 pylint 时,我什么也没得到。我启用了 linting,并选择了运行 pylint,但它什么也没给我。以下是我的settings.json:

{
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
    "git.confirmSync": false,
    "python.linting.enabled": true,
    "window.zoomLevel": -2,
    "python.pythonPath": "C:\\Users\\becky\\AppData\\Local\\Programs\\Python\\Python38- 
      32\\python.exe",
    "files.autoSave": "off",
    "terminal.integrated.automationShell.linux": "",
    "python.linting.pylintEnabled": true,
    "python.linting.pylintUseMinimalCheckers": false,
    "terminal.integrated.env.linux": {
    },
    "terminal.integrated.automationShell.windows": "",
    "python.autoComplete.extraPaths": [
    ],
    "workbench.editorAssociations": [
    {
        "viewType": "jupyter.notebook.ipynb",
        "filenamePattern": "*.ipynb"
    }
]

}

VSCOde settings.json

我没有固定在任何特别花哨的设置上,因此很乐意完全更改 settings.json,我只希望我的默认终端是 bash 并且 linting 能够正常运行(尤其是在保存时)。

如果你能帮忙,请告诉我!

谢谢!!

编辑:

如果我在 VSCode 终端中运行 pip show pylint,将返回以下内容:

【问题讨论】:

    标签: python visual-studio-code vscode-settings pylint


    【解决方案1】:

    对于其他为此苦苦挣扎的人,我通过重新安装 VSCode 并从头开始解决它,如下所示:

    1. 已卸载 VSCode
    2. 删除了我的“User/AppData/Roaming/Code”文件夹
    3. 删除了我的“用户/[uname]/.vscode
    4. 重新安装了 VSCode,它是全新的,我的旧设置/脚本都没有打开。
    5. 安装了我需要的 VSCode extras(Python、WSL 和 Pylint 扩展)
    6. 在我的终端中运行pip install pylint
    7. 在我的终端中从我的脚本所在的文件夹中运行pylint --generate-rcfile | Out-File -Encoding utf8 .pylintrc(不确定我是否每次都必须这样做!)
    8. 重新启动 VSCode,它运行良好!

    (您需要删除的文件夹的位置可能有所不同,我不得不为我挖掘一下。我也无法在我常用的文件资源管理器中看到它们,所以我不得不通过命令行 - 我使用bash 模拟器)

    This website 很有帮助:

    【讨论】:

      【解决方案2】:

      请检查VS Code当前使用的python环境中是否已经安装了模块“pylint”:(pip show pylint)

      如果没有显示模块“pylint”的信息,可以使用“pip”安装在这个环境中:pip install pylint;或者您可以将 python 环境切换到安装了“pylint”的环境。

      这里会自动显示“Pylint”信息:

      参考:Pylint in VS CodePython Environment in VSCode.

      【讨论】:

      • 嘿!运行 pip show pylint 按预期返回完整输出,我将输出作为主要问题中的编辑
      • @Becky Heath - 你试过重新加载 VS Code 吗?请尝试重新安装“pylint”。
      • 我刚刚运行 pip install 的 pylint,并升级了 pylint。然后我关闭了VSCode并重新启动它,问题仍然存在!
      • @Becky Heath - 你在 VS Code 中使用了哪些扩展?而且由于VS Code中有两个“settings.json”,所以建议你检查一下其他“settings.json”中是否设置了“Pylint”。
      • 哦!我如何找到另一个?这个“settings.json”是通过VSCode设置找到的?
      猜你喜欢
      • 2019-09-25
      • 1970-01-01
      • 2021-02-11
      • 2021-12-24
      • 2012-06-04
      • 2022-07-26
      • 1970-01-01
      • 2019-09-07
      相关资源
      最近更新 更多