microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.32k stars 1.19k forks source link

Stuck at "Discovering Python interpreter" #23303

Closed LazarusX closed 6 months ago

LazarusX commented 6 months ago

Type: Bug

Behaviour

Endless "Discovering Python interpreter". The extension's features such as Go-to-definition does not work. I have both VS Code stable with release version of the extension, as well as VS Code Insiders with pre-release version. Both environment can reproduce the issue.

Steps to reproduce:

  1. Just open a workspace with Python files
  2. Open any Python file and see the endless message.

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` 2024-04-29 20:52:32.554 [info] 试验“pythonaa”处于活动状态 2024-04-29 20:52:32.554 [info] 试验“pythonRecommendTensorboardExt”处于活动状态 2024-04-29 20:52:32.554 [info] 试验“pythonREPLSmartSend”处于活动状态 2024-04-29 20:52:32.554 [info] 试验“pythonTerminalEnvVarActivation”处于活动状态 2024-04-29 20:52:32.554 [info] 试验“pythonTestAdapter”处于活动状态 2024-04-29 20:52:32.569 [info] Default formatter is set to null for workspace /Users/lazarusx/Projects/intelligent-center 2024-04-29 20:52:32.576 [info] Test server listening. 2024-04-29 20:52:32.579 [info] > conda info --json 2024-04-29 20:52:32.582 [info] > hatch env show --json 2024-04-29 20:52:32.582 [info] cwd: . 2024-04-29 20:52:32.584 [info] > pyenv which python 2024-04-29 20:52:32.584 [info] cwd: . 2024-04-29 20:52:32.587 [info] > ~/.conda/bin/conda info --json 2024-04-29 20:52:32.748 [info] Found: /usr/bin/python3 --> /usr/bin/python3 2024-04-29 20:52:32.782 [info] > pyenv which python 2024-04-29 20:52:32.782 [info] cwd: . 2024-04-29 20:52:32.797 [info] Found: /opt/homebrew/bin/python3 --> /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/bin/python3.12 2024-04-29 20:52:32.798 [info] Found: /opt/homebrew/bin/python3.10 --> /opt/homebrew/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/bin/python3.10 2024-04-29 20:52:32.798 [info] Found: /opt/homebrew/bin/python3.11 --> /opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/bin/python3.11 2024-04-29 20:52:32.799 [info] > ~/.virtualenvs/address-crawler-w6jYIZUv/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:32.802 [info] Found: /opt/homebrew/bin/python3.12 --> /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/bin/python3.12 2024-04-29 20:52:32.803 [info] Found: /opt/homebrew/bin/python3.9 --> /opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/bin/python3.9 2024-04-29 20:52:32.805 [info] > ~/.local/share/virtualenvs/address-crawler-w6jYIZUv/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:32.835 [info] > /usr/bin/python3 -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:32.845 [error] [Error: Command failed: /Users/lazarusx/.virtualenvs/address-crawler-w6jYIZUv/bin/python -I /Users/lazarusx/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py /Users/lazarusx/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py dyld[87735]: Library not loaded: @executable_path/../.Python Referenced from: /Users/lazarusx/.local/share/virtualenvs/address-crawler-w6jYIZUv/bin/python3.7 Reason: tried: '/Users/lazarusx/.local/share/virtualenvs/address-crawler-w6jYIZUv/.Python' (no such file), '/usr/local/lib/.Python' (no such file), '/usr/lib/.Python' (no such file, not in dyld cache) at ChildProcess.exithandler (node:child_process:423:12) at ChildProcess.emit (node:events:529:35) at maybeClose (node:internal/child_process:1098:16) at Socket. (node:internal/child_process:450:11) at Socket.emit (node:events:517:28) at Pipe. (node:net:350:12)] { code: null, killed: false, signal: 'SIGABRT', cmd: '/Users/lazarusx/.virtualenvs/address-crawler-w6jYIZUv/bin/python -I /Users/lazarusx/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py /Users/lazarusx/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py' } 2024-04-29 20:52:32.946 [info] > /opt/homebrew/bin/python3 -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:33.037 [info] > /opt/homebrew/bin/python3.10 -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:33.102 [info] > /opt/homebrew/bin/python3.11 -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:33.157 [info] > /opt/homebrew/bin/python3.9 -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:33.206 [info] > ./venv/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:34.847 [info] > ~/.virtualenvs/address-crawler-w6jYIZUv/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.4.1/python_files/interpreterInfo.py 2024-04-29 20:52:43.441 [info] Python 解释器路径: ./venv/bin/python 2024-04-29 20:53:22.576 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-29 20:53:22.779 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-29 20:53:22.779 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-29 20:53:22.779 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-29 20:53:30.790 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. ```

Extension version: 2024.4.1 VS Code version: Code - Insiders 1.89.0-insider (Universal) (b55887a7d96669ea2e70baff32bb2288c640d015, 2024-04-26T13:06:22.512Z) OS version: Darwin arm64 23.4.0 Modes:

User Settings

``` languageServer: "Pylance" testing • pytestArgs: "" • pytestEnabled: true ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |autopep8|ms-python.autopep8|2024.0.0| |Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code|MS-CEINTL.vscode-language-pack-zh-hans|1.89.2024042409| |Flake8|ms-python.flake8|2023.10.0| |isort|ms-python.isort|2023.10.1| |JavaScript Debugger|ms-vscode.js-debug|1.89.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |Pylance|ms-python.vscode-pylance|2024.4.1| |Python|ms-python.python|2024.4.1| |Python Debugger|ms-python.debugpy|2024.4.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9|
System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (8 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|10, 7, 6| |Memory (System)|16.00GB (0.08GB free)| |Process Argv|--crash-reporter-id 13dfec1b-6da1-46de-b821-73dcad7d053f| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 vsaa593cf:30376535 py29gd2263:31024238 c4g48928:30535728 962ge761:30841072 pythongtdpath:30726887 pythonidxpt:30768918 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 dsvsc015:30821418 pythontestfixt:30866404 pythonregdiag2:30926734 pyreplss1:30879911 pythonmypyd1:30859725 pythoncet0:30859736 h48ei257:31000450 pythontbext0:30879054 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 cppperfnew:30980852 fegfb526:30952798 bg6jg535:30979844 ccp2r6:30958154 pythonait:30973460 gee8j676:31009450 g316j359:31013175 pythoncenvpt:31022790 a69g1124:31018687 j0bi8933:31021562 dvdeprecation:31030041 pythonprt:31030356 ```
anthonykim1 commented 6 months ago

Hi @LazarusX Thanks for filing the issue. Can you try clearing cache and reloading? It can be found in command palette via control+shift+p (command+shift+p in mac)

Screenshot 2024-04-29 at 9 58 20 AM
LazarusX commented 6 months ago

@anthonykim1 I tried, but it's not working.

anthonykim1 commented 6 months ago
Screenshot 2024-04-30 at 12 12 00 AM

@LazarusX Can you try downgrading/installing previous version(s) of the Python extension and see if you can still repro the problem? I'm wondering if this is some sort of regression on discovering Python interpreter.

LazarusX commented 6 months ago

@anthonykim1 I remember the endless "Discovering Python Interpreter" issue happened for me since a update around early April. However, at that time, IntelliSense features such as Go-to-Definition and autocompletion still worked. I did a "Clear Cache and Reload Window" last night to see if it helps. After the reloading, the "Discovering Python Interpreter" still existed and IntelliSense also broke.

I just did a series of downgrading (as well as "Clear Cache and Reload Window"), all the way back to v2023.22.1. Both issues still exist.

Here are the output:

``` 2024-04-30 16:05:10.941 [info] 试验“pythonaa”处于活动状态 2024-04-30 16:05:10.941 [info] 试验“pythonRecommendTensorboardExt”处于活动状态 2024-04-30 16:05:10.941 [info] 试验“pythonREPLSmartSend”处于活动状态 2024-04-30 16:05:10.941 [info] 试验“pythonTerminalEnvVarActivation”处于活动状态 2024-04-30 16:05:10.941 [info] 试验“pythonTestAdapter”处于活动状态 2024-04-30 16:05:10.952 [info] Default formatter is set to null for workspace /Users/lazarusx/Projects/intelligent-center 2024-04-30 16:05:10.959 [info] Test server listening. 2024-04-30 16:05:10.961 [info] > conda info --json 2024-04-30 16:05:11.136 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS 2024-04-30 16:05:11.139 [info] > ~/.conda/bin/conda info --json 2024-04-30 16:05:11.142 [info] Found: /usr/bin/python3 --> /usr/bin/python3 2024-04-30 16:05:11.143 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS 2024-04-30 16:05:11.143 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS 2024-04-30 16:05:11.143 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS 2024-04-30 16:05:11.143 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS 2024-04-30 16:05:11.143 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS 2024-04-30 16:05:11.143 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS 2024-04-30 16:05:11.144 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS 2024-04-30 16:05:11.144 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS 2024-04-30 16:05:11.164 [info] Found: /opt/homebrew/bin/python3 --> /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/bin/python3.12 2024-04-30 16:05:11.166 [info] > ~/.virtualenvs/address-crawler-w6jYIZUv/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2023.22.1/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.22.1/pythonFiles/interpreterInfo.py 2024-04-30 16:05:11.166 [info] Found: /opt/homebrew/bin/python3.10 --> /opt/homebrew/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/bin/python3.10 2024-04-30 16:05:11.167 [info] Found: /opt/homebrew/bin/python3.11 --> /opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/bin/python3.11 2024-04-30 16:05:11.167 [info] Found: /opt/homebrew/bin/python3.12 --> /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/bin/python3.12 2024-04-30 16:05:11.168 [info] Found: /opt/homebrew/bin/python3.9 --> /opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/bin/python3.9 2024-04-30 16:05:11.169 [info] > ~/.local/share/virtualenvs/address-crawler-w6jYIZUv/bin/python -I ~/.vscode-insiders/extensions/ms-python.python-2023.22.1/pythonFiles/get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2023.22.1/pythonFiles/interpreterInfo.py 2024-04-30 16:06:00.976 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:00.989 [info] > python -c "import sys;print(sys.executable)" 2024-04-30 16:06:01.003 [error] [Error: Command failed: python -c "import sys;print(sys.executable)" /bin/sh: python: command not found at ChildProcess.exithandler (node:child_process:423:12) at ChildProcess.emit (node:events:529:35) at maybeClose (node:internal/child_process:1098:16) at Socket. (node:internal/child_process:450:11) at Socket.emit (node:events:517:28) at Pipe. (node:net:350:12)] { code: 127, killed: false, signal: null, cmd: 'python -c "import sys;print(sys.executable)"' } 2024-04-30 16:06:01.136 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:01.137 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:01.137 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:12.717 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:51.012 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:51.149 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:51.152 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:06:51.152 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:07:02.741 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:07:27.888 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. 2024-04-30 16:07:36.710 [error] Autoselection timeout out, this is likely a issue with how consumer called execution factory API. Using default python to execute. ```
LazarusX commented 6 months ago

OK. I think I found the solution myself. After removing the environment ~/.local/share/virtualenvs/address-crawler-w6jYIZUv/ mentioned in the output, everything worked fine again.

anthonykim1 commented 6 months ago

@LazarusX Nice. Was ~/.local/share/virtualenvs/address-crawler-w6jYIZUv/ some sort of stagnant virtual env you had?

LazarusX commented 6 months ago

@anthonykim1 Yes. It's migrated from my last machine, and only used a few years ago. I have no idea why it's scanned as a potential environment. However, IMO, there could be enhancement for this situation, because a broken environment should not block the entire interpreter discovery process. I also believe there is sort of regression here, because the extension used to work fine in spite of the broken environment.