microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 294 forks source link

Expose a unified way to retrieve Python Env Associated with Jupyter Notebooks #15987

Open DonJayamanne opened 2 months ago

DonJayamanne commented 2 months ago

Currently there's a private API that Pylance gets to use in order to determine the Python Env associated with Jupyter notebooks. Unfortunately there are a few problems with this API:

Pros:

Solution:

Internally, the call to getActiveEnvironmentPath(resource?: Resource): EnvironmentPath; would now handle Uris a little differently. If the Uri is a notebook Uri, then get the interpreter from Jupyter extension (using existing code). The check if the Uri is a notebook can optionally be passed into Jupyter as well, i.e. keep it super simple.