vscode-jupyter: Jupyter notebook kernel changes not detected to Pylance
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
Actual behaviour
Pylance will only detect kernel changes if you change the interpreter via the command palette
Before changing via command palette
After changing
Imports resolve
Steps to reproduce:
- Create a venv and install any pip module foo
- Create a notebook and import foo
- The pylance import detection will not update via changing kernel
- 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 😃
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 24 (19 by maintainers)
Hello, folks.
I’ve found a workaround for this issue. I’ve to configure python.analysis.extraPaths in settings.json of the current project in VSCode: { “python.analysis.extraPaths”: [ “path_to_venv_site_pakages” ], }
I’m working in a local project with a conda venv enviroment, so the config looks like: { “python.analysis.extraPaths”: [ “D:\Users\hs\Envs\udemyDSPy\lib\site-packages” ], } As the config is specific to project, we can change this in other projects to point the right venv packages import location.
*Note.: I’m using VSCode 1.64.2 version.
Woo hoo…