使用 pylint 扩展时 VSCode 中出现 FileNotFoundError

问题描述 投票:0回答:1

最近在 VSCode 中运行 pylint 时收到以下错误消息。 当我使用“pylint ”在 cmd 中运行 pylint 时,它工作得很好。 直到几周前,它的效果都很好。系统没有发生明显的变化。

VSCode版本:1.87.2 python版本:3.12.0和3.9.5 操作系统:windows10

2024-03-14 00:26:15.324 [info] [Trace - 12:26:15 AM] Sending notification 'textDocument/didSave'.
2024-03-14 00:26:15.332 [info] [Trace - 12:26:15 AM] Received notification 'window/logMessage'.
2024-03-14 00:26:15.332 [info] --max-line-length=120 --reports=n --output-format=json --max-line-length=120 --from-stdin c:\Users\test_user\Desktop\Untitled-1.py
2024-03-14 00:26:15.332 [info] [Trace - 12:26:15 AM] Received notification 'window/logMessage'.
2024-03-14 00:26:15.332 [info] CWD Server: C:\Users\test_user\Desktop
2024-03-14 00:26:15.346 [info] [Trace - 12:26:15 AM] Received notification 'window/logMessage'.
2024-03-14 00:26:15.346 [info] [Error - 12:26:15 AM] Linting failed with error:
Traceback (most recent call last):
  File "c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py", line 144, in _linting_helper
    result = _run_tool_on_document(document, use_stdin=True, extra_args=extra_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py", line 736, in _run_tool_on_document
    result = utils.run_path(
             ^^^^^^^^^^^^^^^
  File "c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_utils.py", line 226, in run_path
    with subprocess.Popen(
         ^^^^^^^^^^^^^^^^^
  File "c:\Program Files\Python312\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "c:\Program Files\Python312\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

2024-03-14 00:26:15.347 [info] [Trace - 12:26:15 AM] Received notification 'textDocument/publishDiagnostics'.

如有任何建议,我们将不胜感激,谢谢

  • 检查了 pylint github 存储库中的相关问题和 stackoverflow,但找不到任何相关内容
  • 重新安装 pylint 扩展没有帮助
  • 删除 VSCode 工作区没有帮助
python visual-studio-code pylint
1个回答
0
投票

执行了以下操作:

  • 再次重新安装 pylint 扩展 -> 没有效果
  • 删除了 C:\Users est_user\AppData\Roaming\Python\Python312 因为它或多或少是空的(在另一台电脑上不可用)->没有效果
  • 使用系统安装程序而不是用户安装程序重新安装 VSCode -> 没有效果
  • 检查了我的用户settings.json中的pylint相关设置(如初始日志中所示)
    • “pylint.args”:[“--max-line-length = 120”]
    • "pylint.path": ["--max-line-length=120"] -> 这个导致了问题。它在以前的版本中工作正常,但使用其中之一 最新更新它不再起作用了。然而,这个论点确实 不属于路径设置。
© www.soinside.com 2019 - 2024. All rights reserved.