non-Pylance intellisense features fail in notebook context only #23897
Labels
area-intellisense
LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.
bug
Issue identified by VS Code Team member as probable bug
needs PR
Ready to be worked on
verified
Verification succeeded
Milestone
Environment data
Expected behaviour
With a new python environment, create a new file with a single import statement (import os). If in a .py file, Intellisense work on this import (either hover hint or go to def) even if Pylance is not installed, falling back to Jedi if python.languageServer is set to Default or explicitly to Jedi (or even using pyright if the extension is installed and python.languageServer is set to None).
This should also work if the same line is in a notebook.
Actual behaviour
non-Pylance intellisense only works as expected in the notebook for jupyter v2023.9.100, python v2024.2.1 or older. For newer extension versions a "No definition found" hover appears instead. Additionally (and possibly related) the same failure occurs even in older versions when python.languageServer is set to Default and Pylance is not installed.
(Previously reported as microsoft/vscode-jupyter#15702, but adding more details here)
Steps to reproduce:
import os
os
and see the failure result hovertext.os
and see the correct source file openLogs
Output for
Jupyter
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toJupyter
)Visual Studio Code (1.89.1, undefined, desktop) Jupyter Extension Version: 2024.1.0. Python Extension Version: 2024.0.0. Pylance Extension Version: 2024.3.2. Platform: darwin (arm64). Workspace folder ~/code/TReND_2024, Home = /Users/tom.chartrand 15:16:47.614 [debug] Get Custom Env Variables, Class name = Tm (started execution), Arg 1: undefined, Arg 2: "RunPythonCode" 15:16:47.617 [info] Start refreshing Kernel Picker (1722464207617) 15:16:47.642 [info] Not using Pylance 15:16:47.694 [debug] No controller, hence notebook communications cannot be initialized for editor ~/code/TReND_2024/code/Day 1 - Data access.ipynb 15:16:47.694 [info] Start refreshing Interpreter Kernel Picker 15:16:47.851 [debug] Get Custom Env Variables, Class name = Tm, completed in 237ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode" 15:16:47.851 [debug] Jupyter Paths /kernels: 15:16:47.852 [debug] Kernel Spec Root Paths, /usr/share/jupyter/kernels, /usr/local/share/jupyter/kernels, ~/Library/Jupyter/kernels 15:16:47.860 [debug] Search for KernelSpecs in Interpreter /usr/bin/python3 15:16:47.860 [debug] Finding Global Python KernelSpecs 15:16:47.860 [debug] Search for KernelSpecs in Interpreter /opt/homebrew/bin/python3 15:16:47.860 [debug] Search for KernelSpecs in Interpreter ~/micromamba/bin/python 15:16:47.860 [debug] Search for KernelSpecs in Interpreter ~/code/thalamus-merfish-analysis/.conda/bin/python 15:16:47.860 [debug] Search for KernelSpecs in Interpreter ~/micromamba/envs/thalamus-merfish-analysis/bin/python 15:16:47.860 [debug] Search for KernelSpecs in Interpreter ~/code/TReND_2024/.conda/bin/python 15:16:47.861 [debug] Full interpreter list is length: 6, /usr/bin/python3::Unknown:/usr/bin/python3, /opt/homebrew/bin/python3::Unknown:/opt/homebrew/bin/python3, ~/micromamba/bin/python:base:Conda:~/micromamba/bin/python, ~/code/thalamus-merfish-analysis/.conda/bin/python::Conda:~/code/thalamus-merfish-analysis/.conda/bin/python, ~/micromamba/envs/thalamus-merfish-analysis/bin/python:thalamus-merfish-analysis:Conda:~/micromamba/envs/thalamus-merfish-analysis/bin/python, ~/code/TReND_2024/.conda/bin/python::Conda:~/code/TReND_2024/.conda/bin/python 15:16:47.861 [debug] Getting activated env variables, Class name = mp (started execution), Arg 1: "~/code/TReND_2024", Arg 2: "~/code/TReND_2024/.conda/bin/python", Arg 3: undefined 15:16:47.861 [debug] Get Custom Env Variables, Class name = Tm (started execution), Arg 1: "~/code/TReND_2024", Arg 2: "RunPythonCode" 15:16:47.861 [debug] Get Custom Env Variables, Class name = Tm, completed in 0ms, has a truthy return value, Arg 1: "~/code/TReND_2024", Arg 2: "RunPythonCode" 15:16:48.013 [debug] Kernels for interpreter /usr/bin/python3 are .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher 15:16:48.013 [debug] Kernels for interpreter /opt/homebrew/bin/python3 are .jvsc74a57bd0b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e./opt/homebrew/bin/python3./opt/homebrew/bin/python3.-m#ipykernel_launcher 15:16:48.013 [debug] Kernels for interpreter ~/code/thalamus-merfish-analysis/.conda/bin/python are .jvsc74a57bd0462bc6e82b7cda20ccdaaa76001fa99e907d0ae5cd6f47252032093caa024858.~/code/thalamus-merfish-analysis/.conda/python.~/code/thalamus-merfish-analysis/.conda/python.-m#ipykernel_launcher 15:16:48.013 [debug] Kernels for interpreter ~/micromamba/envs/thalamus-merfish-analysis/bin/python are .jvsc74a57bd0ad8cbf621e39bc5b4fc71e5ed08f37e70b9e09661c455a262894b686b9356bd4.~/micromamba/envs/thalamus-merfish-analysis/python.~/micromamba/envs/thalamus-merfish-analysis/python.-m#ipykernel_launcher 15:16:48.578 [debug] KernelProvider switched kernel to id = .jvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be.~/code/TReND_2024/.conda/python.~/code/TReND_2024/.conda/python.-m#ipykernel_launcher 15:16:48.578 [debug] Initialize notebook communications for editor ~/code/TReND_2024/code/Day 1 - Data access.ipynb 15:16:48.578 [debug] Resolving notebook UI Comms (resolve) for ~/code/TReND_2024/code/Day 1 - Data access.ipynb 15:16:48.578 [debug] initialize CommonMessageCoordinator 15:16:48.580 [debug] Registering commtarget jupyter.widget 15:16:48.580 [debug] IPyWidgetMessageDispatcher.initialize 15:16:48.580 [debug] Attempting to determine version of IPyWidgets 15:16:48.581 [debug] Controller selection change completed 15:16:48.581 [debug] Waiting for IPyWidgets version 15:16:48.581 [debug] Waiting for IPyWidgets version promise 15:16:48.588 [debug] Loading kernelspec from ~/micromamba/share/jupyter/kernels/python3/kernel.json for ~/micromamba/bin/python 15:16:48.588 [debug] Loading kernelspec from ~/code/TReND_2024/.conda/share/jupyter/kernels/python3/kernel.json for ~/code/TReND_2024/.conda/bin/python 15:16:48.736 [debug] Hiding default kernel spec 'Python 3 (ipykernel)', 'pythonjvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be', /python for interpreter ~/code/TReND_2024/.conda/bin/python and spec ~/code/TReND_2024/.conda/share/jupyter/kernels/python3/kernel.json 15:16:48.736 [debug] Kernels for interpreter ~/code/TReND_2024/.conda/bin/python are .jvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be.~/code/TReND_2024/.conda/python.~/code/TReND_2024/.conda/python.-m#ipykernel_launcher 15:16:48.736 [debug] Hiding default kernel spec 'Python 3 (ipykernel)', 'pythonjvsc74a57bd0e8d528e49feaf371ca3d5928543ccc82e8f8fa60e7e26dffcf7e9f9692d19768', ~/micromamba/bin/python for interpreter ~/micromamba/bin/python and spec ~/micromamba/share/jupyter/kernels/python3/kernel.json 15:16:48.736 [debug] Kernels for interpreter ~/micromamba/bin/python are .jvsc74a57bd0e8d528e49feaf371ca3d5928543ccc82e8f8fa60e7e26dffcf7e9f9692d19768.~/micromamba/python.~/micromamba/python.-m#ipykernel_launcher 15:16:48.742 [debug] Conda file returned by Python Extension is ~/micromamba/condabin/conda 15:16:49.413 [debug] Full interpreter list is length: 6, /usr/bin/python3::Unknown:/usr/bin/python3, /opt/homebrew/bin/python3::Unknown:/opt/homebrew/bin/python3, ~/micromamba/bin/python:base:Conda:~/micromamba/bin/python, ~/code/thalamus-merfish-analysis/.conda/bin/python::Conda:~/code/thalamus-merfish-analysis/.conda/bin/python, ~/micromamba/envs/thalamus-merfish-analysis/bin/python:thalamus-merfish-analysis:Conda:~/micromamba/envs/thalamus-merfish-analysis/bin/python, ~/code/TReND_2024/.conda/bin/python::Conda:~/code/TReND_2024/.conda/bin/python 15:16:49.413 [debug] Refreshed Environments 15:16:49.489 [debug] Got env vars with python ~/code/TReND_2024/.conda/bin/python, with env var count 47 in 1628ms. PATH value is ~/code/TReND_2024/.conda/bin:~/micromamba/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:~/.local/bin:~/.local/bin and Path value is undefined 15:16:49.489 [debug] Prepend PATH with python bin for ~/code/TReND_2024/.conda/bin/python 15:16:49.489 [debug] Activated Env Variables for ~/code/TReND_2024/.conda/bin/python, PATH value is ~/code/TReND_2024/.conda/bin:~/micromamba/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:~/.local/bin:~/.local/bin and Path value is undefined 15:16:49.489 [debug] Getting activated env variables, Class name = mp, completed in 1628ms, has a truthy return value, Arg 1: "~/code/TReND_2024", Arg 2: "~/code/TReND_2024/.conda/bin/python", Arg 3: undefined 15:16:49.490 [info] Process Execution: ~/code/TReND_2024/.conda/bin/python -m pip list 15:16:50.418 [info] End refreshing Kernel Picker (1722464207617)
Compare to successful execution on older extension version:
Output for
Jupyter
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toJupyter
)Visual Studio Code (1.89.1, undefined, desktop) Jupyter Extension Version: 2023.9.1102792234. Python Extension Version: 2024.0.0. Platform: darwin (arm64). Workspace folder ~/code/TReND_2024, Home = /Users/tom.chartrand 15:13:40.660 [info] User belongs to experiment group 'NewJupyterSession' 15:13:40.809 [debug] Get Custom Env Variables, Class name = Kl (started execution), Arg 1: undefined, Arg 2: "RunPythonCode" 15:13:40.809 [info] Start refreshing Kernel Picker (1722464020809) 15:13:40.811 [info] Not using Pylance 15:13:40.954 [info] Start refreshing Interpreter Kernel Picker 15:13:41.177 [debug] Get Custom Env Variables, Class name = Kl, completed in 368ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode" 15:13:41.177 [debug] Jupyter Paths /kernels: 15:13:41.179 [debug] Kernel Spec Root Paths, /usr/share/jupyter/kernels, /usr/local/share/jupyter/kernels, ~/Library/Jupyter/kernels 15:13:41.200 [debug] Search for KernelSpecs in Interpreter ~/code/TReND_2024/.conda/bin/python 15:13:41.200 [debug] Finding Global Python KernelSpecs 15:13:41.201 [debug] Search for KernelSpecs in Interpreter /opt/homebrew/bin/python3 15:13:41.201 [debug] Search for KernelSpecs in Interpreter /usr/bin/python3 15:13:41.201 [debug] Search for KernelSpecs in Interpreter ~/micromamba/bin/python 15:13:41.202 [debug] Search for KernelSpecs in Interpreter ~/code/thalamus-merfish-analysis/.conda/bin/python 15:13:41.202 [debug] Search for KernelSpecs in Interpreter ~/micromamba/envs/thalamus-merfish-analysis/bin/python 15:13:41.202 [debug] Full interpreter list is length: 6, /opt/homebrew/bin/python3::Unknown:/opt/homebrew/bin/python3, /usr/bin/python3::Unknown:/usr/bin/python3, ~/micromamba/bin/python:base:Conda:~/micromamba/bin/python, ~/code/thalamus-merfish-analysis/.conda/bin/python::Conda:~/code/thalamus-merfish-analysis/.conda/bin/python, ~/micromamba/envs/thalamus-merfish-analysis/bin/python:thalamus-merfish-analysis:Conda:~/micromamba/envs/thalamus-merfish-analysis/bin/python, ~/code/TReND_2024/.conda/bin/python::Conda:~/code/TReND_2024/.conda/bin/python 15:13:41.203 [debug] Getting activated env variables, Class name = za (started execution), Arg 1: "~/code/TReND_2024", Arg 2: "~/code/TReND_2024/.conda/bin/python", Arg 3: undefined 15:13:41.203 [debug] Get Custom Env Variables, Class name = Kl (started execution), Arg 1: "~/code/TReND_2024", Arg 2: "RunPythonCode" 15:13:41.203 [debug] Get Custom Env Variables, Class name = Kl, completed in 0ms, has a truthy return value, Arg 1: "~/code/TReND_2024", Arg 2: "RunPythonCode" 15:13:41.817 [debug] Kernels for interpreter /opt/homebrew/bin/python3 are .jvsc74a57bd0b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e./opt/homebrew/bin/python3./opt/homebrew/bin/python3.-m#ipykernel_launcher 15:13:41.818 [debug] Kernels for interpreter /usr/bin/python3 are .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher 15:13:41.818 [debug] Kernels for interpreter ~/code/thalamus-merfish-analysis/.conda/bin/python are .jvsc74a57bd0462bc6e82b7cda20ccdaaa76001fa99e907d0ae5cd6f47252032093caa024858.~/code/thalamus-merfish-analysis/.conda/python.~/code/thalamus-merfish-analysis/.conda/python.-m#ipykernel_launcher 15:13:41.818 [debug] Kernels for interpreter ~/micromamba/envs/thalamus-merfish-analysis/bin/python are .jvsc74a57bd0ad8cbf621e39bc5b4fc71e5ed08f37e70b9e09661c455a262894b686b9356bd4.~/micromamba/envs/thalamus-merfish-analysis/python.~/micromamba/envs/thalamus-merfish-analysis/python.-m#ipykernel_launcher 15:13:41.846 [debug] KernelProvider switched kernel to id = .jvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be.~/code/TReND_2024/.conda/python.~/code/TReND_2024/.conda/python.-m#ipykernel_launcher 15:13:41.846 [debug] Initialize notebook communications for editor ~/code/TReND_2024/code/Day 1 - Data access.ipynb 15:13:41.846 [debug] Resolving notebook UI Comms (resolve) for ~/code/TReND_2024/code/Day 1 - Data access.ipynb 15:13:41.847 [debug] initialize CommonMessageCoordinator 15:13:41.847 [debug] Registering commtarget jupyter.widget 15:13:41.847 [debug] IPyWidgetMessageDispatcher.initialize 15:13:41.847 [debug] Attempting to determine version of IPyWidgets 15:13:41.848 [debug] Controller selection change completed 15:13:41.848 [debug] Waiting for IPyWidgets version 15:13:41.848 [debug] Waiting for IPyWidgets version promise 15:13:41.858 [debug] Loading kernelspec from ~/code/TReND_2024/.conda/share/jupyter/kernels/python3/kernel.json for ~/code/TReND_2024/.conda/bin/python 15:13:41.858 [debug] Loading kernelspec from ~/micromamba/share/jupyter/kernels/python3/kernel.json for ~/micromamba/bin/python 15:13:41.902 [debug] Conda file returned by Python Extension is ~/micromamba/condabin/conda 15:13:41.914 [debug] Kernel Specs found in interpreter ~/micromamba/bin/python are [{"specFile":"~/micromamba/share/jupyter/kernels/python3/kernel.json","interpreterPath":"~/micromamba/bin/python","isRegisteredByVSC":"registeredByNewVersionOfExt","name":"pythonjvsc74a57bd0e8d528e49feaf371ca3d5928543ccc82e8f8fa60e7e26dffcf7e9f9692d19768","argv":["~/micromamba/bin/python","-m","ipykernel_launcher","-f","{connection_file}"],"language":"python","executable":"~/micromamba/bin/python","display_name":"Python 3 (ipykernel)","metadata":{"debugger":true,"vscode":{"originalSpecFile":"~/micromamba/share/jupyter/kernels/python3/kernel.json","originalDisplayName":"Python 3 (ipykernel)"}}}] 15:13:41.914 [debug] Hiding default kernel spec 'Python 3 (ipykernel)', 'pythonjvsc74a57bd0e8d528e49feaf371ca3d5928543ccc82e8f8fa60e7e26dffcf7e9f9692d19768', ~/micromamba/bin/python for interpreter ~/micromamba/bin/python and spec ~/micromamba/share/jupyter/kernels/python3/kernel.json 15:13:41.914 [debug] Kernels for interpreter ~/micromamba/bin/python are .jvsc74a57bd0e8d528e49feaf371ca3d5928543ccc82e8f8fa60e7e26dffcf7e9f9692d19768.~/micromamba/python.~/micromamba/python.-m#ipykernel_launcher 15:13:41.914 [debug] Kernel Specs found in interpreter ~/code/TReND_2024/.conda/bin/python are [{"specFile":"~/code/TReND_2024/.conda/share/jupyter/kernels/python3/kernel.json","interpreterPath":"~/code/TReND_2024/.conda/bin/python","isRegisteredByVSC":"registeredByNewVersionOfExt","name":"pythonjvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be","argv":["python","-m","ipykernel_launcher","-f","{connection_file}"],"language":"python","executable":"python","display_name":"Python 3 (ipykernel)","metadata":{"debugger":true,"vscode":{"originalSpecFile":"~/code/TReND_2024/.conda/share/jupyter/kernels/python3/kernel.json","originalDisplayName":"Python 3 (ipykernel)"}}}] 15:13:41.914 [debug] Hiding default kernel spec 'Python 3 (ipykernel)', 'pythonjvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be', /python for interpreter ~/code/TReND_2024/.conda/bin/python and spec ~/code/TReND_2024/.conda/share/jupyter/kernels/python3/kernel.json 15:13:41.915 [debug] Kernels for interpreter ~/code/TReND_2024/.conda/bin/python are .jvsc74a57bd0ee5909fbe5d136e91bacaf8e4da6dc433157c2beefbd22958479532d1801d8be.~/code/TReND_2024/.conda/python.~/code/TReND_2024/.conda/python.-m#ipykernel_launcher 15:13:42.787 [info] Registering dummy command feature 15:13:42.808 [debug] Got env vars with python ~/code/TReND_2024/.conda/bin/python, with env var count 48 in 1605ms. PATH value is ~/code/TReND_2024/.conda/bin:~/micromamba/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:~/.local/bin:~/.local/bin and Path value is undefined 15:13:42.808 [debug] Prepend PATH with python bin for ~/code/TReND_2024/.conda/bin/python, PATH value is ~/code/TReND_2024/.conda/bin:~/micromamba/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:~/.local/bin:~/.local/bin and Path value is undefined 15:13:42.808 [debug] Activated Env Variables for ~/code/TReND_2024/.conda/bin/python, PATH value is ~/code/TReND_2024/.conda/bin:~/micromamba/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:~/.local/bin:~/.local/bin and Path value is undefined 15:13:42.808 [debug] Getting activated env variables, Class name = za, completed in 1605ms, has a truthy return value, Arg 1: "~/code/TReND_2024", Arg 2: "~/code/TReND_2024/.conda/bin/python", Arg 3: undefined 15:13:42.809 [info] Process Execution: ~/code/TReND_2024/.conda/bin/python -m pip list 15:13:43.219 [debug] Full interpreter list is length: 6, /usr/bin/python3::Unknown:/usr/bin/python3, /opt/homebrew/bin/python3::Unknown:/opt/homebrew/bin/python3, ~/micromamba/bin/python:base:Conda:~/micromamba/bin/python, ~/code/thalamus-merfish-analysis/.conda/bin/python::Conda:~/code/thalamus-merfish-analysis/.conda/bin/python, ~/micromamba/envs/thalamus-merfish-analysis/bin/python:thalamus-merfish-analysis:Conda:~/micromamba/envs/thalamus-merfish-analysis/bin/python, ~/code/TReND_2024/.conda/bin/python::Conda:~/code/TReND_2024/.conda/bin/python 15:13:43.219 [debug] Refreshed Environments 15:13:44.222 [info] End refreshing Kernel Picker (1722464020809) 15:13:49.171 [debug] creating new code watcher with matching document file://~/micromamba/lib/python3.9/os.py 15:13:50.559 [debug] notebook communications already initialized for editor ~/code/TReND_2024/code/Day 1 - Data access.ipynb
No idea if this is a useful lead, but I think the line
15:13:42.787 [info] Registering dummy command feature
is present whenever this works, and absent whenever it doesn't.The text was updated successfully, but these errors were encountered: