microsoft / vscode-pylint

Linting support for python using the pylint library.
https://marketplace.visualstudio.com/items?itemName=ms-python.pylint
MIT License
70 stars 34 forks source link

FileNotFoundError when using pylint extension #534

Closed loewekordel closed 5 months ago

loewekordel commented 5 months ago

Recently I get the error message below when running pylint in VSCode. When I run pylint in cmd using "pylint <file/to/python/file> it works just fine. It worked very well until a few weeks ago. No obvious changes have been made to the system.

VSCode version: 1.87.2 python version: 3.12.0 and 3.9.5 operating system: windows10

2024-03-19 17:52:58.086 [info] Name: Pylint
2024-03-19 17:52:58.086 [info] Module: pylint
2024-03-19 17:52:58.086 [info] Python extension loading
2024-03-19 17:52:58.086 [info] Waiting for interpreter from Python extension.
2024-03-19 17:52:58.086 [info] No interpreter found from setting pylint.interpreter
2024-03-19 17:52:58.086 [info] Getting interpreter from ms-python.python extension for workspace c:\Users\test_user\AppData\Local\Programs\Microsoft VS Code
2024-03-19 17:52:58.086 [info] Python extension loaded
2024-03-19 17:52:58.086 [info] Interpreter from ms-python.python extension for c:\Users\test_user\AppData\Local\Programs\Microsoft VS Code: c:\Program Files\Python312\python.exe
2024-03-19 17:52:58.086 [info] Using cwd from `python.analysis.extraPaths`.
2024-03-19 17:52:58.087 [info] Server run command: c:\Program Files\Python312\python.exe c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py
2024-03-19 17:52:58.087 [info] Server: Start requested.
2024-03-19 17:52:59.402 [info] CWD Server: c:\Users\test_user\AppData\Local\Programs\Microsoft VS Code
2024-03-19 17:52:59.403 [info] Settings used to run Server:
[]

2024-03-19 17:52:59.403 [info] Global settings:
{
    "cwd": "${workspaceFolder}",
    "workspace": "C:\\Users\\test_user\\AppData\\Local\\Programs\\Microsoft VS Code",
    "args": [
        "--max-line-length=120"
    ],
    "severity": {
        "convention": "Information",
        "error": "Error",
        "fatal": "Error",
        "refactor": "Hint",
        "warning": "Warning",
        "info": "Information"
    },
    "path": [
        "--max-line-length=120"
    ],
    "ignorePatterns": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "off",
    "extraPaths": []
}

2024-03-19 17:52:59.404 [info] sys.path used to run Server:
   c:\Users\test_user\AppData\Local\Programs\Microsoft VS Code
   c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\libs
   c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool
   c:\Program Files\Python312\python312.zip
   c:\Program Files\Python312\DLLs
   c:\Program Files\Python312\Lib
   c:\Program Files\Python312
   C:\Users\test_user\AppData\Roaming\Python\Python312\site-packages
   C:\Users\test_user\AppData\Roaming\Python\Python312\site-packages\win32
   C:\Users\test_user\AppData\Roaming\Python\Python312\site-packages\win32\lib
   C:\Users\test_user\AppData\Roaming\Python\Python312\site-packages\Pythonwin
   c:\Program Files\Python312\Lib\site-packages
2024-03-19 17:52:59.413 [info] --max-line-length=120 --version
2024-03-19 17:52:59.413 [info] CWD Server: C:\Users\test_user\AppData\Local\Programs\Microsoft VS Code
2024-03-19 17:52:59.425 [info] Error while detecting pylint version:
Traceback (most recent call last):
  File "c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py", line 520, in _log_version_info
    result = _run_tool(["--version"], settings)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py", line 821, in _run_tool
    result = utils.run_path(argv=argv, use_stdin=True, cwd=cwd, env=env)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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-19 17:52:59.435 [info] [Trace - 5:52:59 PM] Sending request 'textDocument/codeAction - (1)'.
2024-03-19 17:52:59.440 [info] c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py:103: DeprecationWarning: 'workspace.get_document' has been deprecated, use 'workspace.get_text_document' instead
  document = LSP_SERVER.workspace.get_document(params.text_document.uri)

2024-03-19 17:52:59.447 [info] [Trace - 5:52:59 PM] Received notification 'window/logMessage'.
2024-03-19 17:52:59.447 [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-19 17:52:59.447 [info] [Trace - 5:52:59 PM] Received notification 'window/logMessage'.
2024-03-19 17:52:59.447 [info] CWD Server: C:\Users\test_user\Desktop
2024-03-19 17:52:59.466 [info] [Trace - 5:52:59 PM] Received notification 'window/logMessage'.
2024-03-19 17:52:59.466 [info] [Error - 5:52:59 PM] 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-19 17:52:59.468 [info] [Trace - 5:52:59 PM] Received notification 'textDocument/publishDiagnostics'.
2024-03-19 17:52:59.476 [info] c:\Users\test_user\.vscode\extensions\ms-python.pylint-2023.10.1\bundled\tool\lsp_server.py:298: DeprecationWarning: 'workspace.get_document' has been deprecated, use 'workspace.get_text_document' instead
  document = LSP_SERVER.workspace.get_document(params.text_document.uri)

2024-03-19 17:52:59.476 [info] [Trace - 5:52:59 PM] Received response 'textDocument/codeAction - (1)' in 41ms.
2024-03-19 17:52:59.499 [info] [Trace - 5:52:59 PM] Sending request 'textDocument/codeAction - (2)'.
2024-03-19 17:52:59.502 [info] [Trace - 5:52:59 PM] Received response 'textDocument/codeAction - (2)' in 3ms.
2024-03-19 17:52:59.796 [info] [Trace - 5:52:59 PM] Sending request 'textDocument/codeAction - (3)'.
2024-03-19 17:52:59.817 [info] [Trace - 5:52:59 PM] Received response 'textDocument/codeAction - (3)' in 21ms.

Any advice would be greatly appreciated, thank you

karthiknadig commented 5 months ago

@loewekordel Can you provide the initial part of the logs where pylint is detected and interpreters are detected? It looks like something is wrong, the arguments like here is not showing the interpreter:

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
loewekordel commented 5 months ago

@karthiknadig updated the logs in my initial comment. python3.12 is installed for all users in c:\Program Files\Python312\ No python installation in \AppData\Local\Programs

loewekordel commented 5 months ago

Did the following: