pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Imports not being found in notebook after changing the kernel

Open rchiodo opened this issue 2 years ago • 4 comments

Follow the directions here:

  • https://github.com/bokeh/tutorial

Open the first notebook Select a kernel that comes from the bk-tutorial environment

Pylance doesn't find the first import:

image

If you reload VS code it will work.

Output log looks like the notebook change event didn't prompt a request for new settings:

2023-11-29 13:25:15.704 [info] (14140) [BG(2)] getSemanticTokens full at C:\Users\rchiodo\source\tutorial\notebooks\01_introduction.ipynb#W3sZmlsZQ==.py (3ms)
2023-11-29 13:25:23.233 [info] (Client) Jupyter provided interpreter path override: c:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\python.exe

That was the only thing that ended up in the log after changing the kernel.

To reproduce after reloading:

  • pick a kernel that doesn't have bokeh installed
  • save the notebook
  • reopen VS code
  • show that the import is not resolved
  • change the kernel to the bk-tutorial kernel again
  • the import will still not be resolved (even though the right kernel is picked)

rchiodo avatar Nov 29 '23 21:11 rchiodo

need to repro on stable to see if this is a regression

judej avatar Nov 30 '23 19:11 judej

This is not a regression, but it can be hard to reproduce.

You might have to reclone the bokeh tutorial to get it to reproduce. I can only reproduce it on never opened files.

rchiodo avatar Nov 30 '23 21:11 rchiodo

Okay I wasn't crazy, this seems to be caused by VS code not sending a kernel change notification: https://github.com/microsoft/vscode-jupyter/issues/15965

rchiodo avatar Dec 01 '23 19:12 rchiodo

I can only repro it with that bokeh tutorial though.

rchiodo avatar Dec 01 '23 19:12 rchiodo

@rchiodo, it looks like the upstream issue has been closed. Can this issue be closed as well?

debonte avatar Apr 18 '25 00:04 debonte

Yeah I think this is fixed now with our latest release and the Jupyter extension's latest release.

rchiodo avatar Apr 18 '25 16:04 rchiodo