question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jupyter notebook kernel changes not detected to Pylance

See original GitHub issue

Environment data

  • VS Code version: 1.57.1
  • Jupyter Extension version (available under the Extensions sidebar): v2021.6.999406279
  • Python Extension version (available under the Extensions sidebar): v2021.6.944021595
  • OS (Windows | Mac | Linux distro) and version: Windows 19043
  • Python and/or Anaconda version: 3.8.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Jupyter server running: Local

Expected behaviour

Upon changing the kernel in the top right Pylance should detect module changes and resolve imports

Code_AIlNLawSya

Actual behaviour

Pylance will only detect kernel changes if you change the interpreter via the command palette

Before changing via command palette Code_5gyZtvgN7r

After changing Code_A4F75UVgZw

Imports resolve

Steps to reproduce:

  1. Create a venv and install any pip module foo
  2. Create a notebook and import foo
  3. The pylance import detection will not update via changing kernel
  4. Changing via Python: Select Interpreter in the command palette will update Pylance

Note: code execution will work as if the venv is selected, but highlighting doesn’t. Another note: I’m sure a lot of my lingo I’m using is incorrect, I’m just starting out 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:23 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Oct 27, 2021

Woo hoo…

0reactions
rchiodocommented, Jul 22, 2022

In a remote situation, pylance isn’t on the remote machine so it doesn’t know anything about the remote environment. In that situation pylance only knows about system modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pylance not working in VSCode Jupyter notebooks
In my case Pylance was ignoring imports and variables. Restarting the Jupyter kernel solved it.
Read more >
Jupyter - Visual Studio Marketplace
A Visual Studio Code extension that provides basic notebook support for language kernels that are supported in Jupyter Notebooks today, ...
Read more >
Jupyter in Visual Studio Code – April 2021 Release - Python
When reopening a newly created Notebook with a Julia kernel, the cells should be detected as Julia. (#5148); Support switching kernels in Native ......
Read more >
Easier Jupyter Notebook Setup for Python in VS Code Tooling
Inlay Hints (source: Microsoft). While the new hints don't change any code, the team is working to provide the ability to add suggested ......
Read more >
Jupyter Notebooks in VS Code Extension NEW in 2022
Jupyter Notebooks in VS Code Extension NEW in 2022 - Tutorial Introducing Kernels, Markdown, & Cells. 13K views 1 year ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found