vscode-jupyter: Detection of Jupyter kernels fails for Python (Microsoft Store version)

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Install Python 3.8 from the Microsoft Store
  2. Run pip install jupyter
  3. Try to run python code through vscode-python

Actual behavior

vscode-python fails to recognize existing kernels.

The point where things start to fall apart is jupyterKernelSpec.ts#parseKernelSpecs, where the response of jupyter kernelspec list gets parsed. Since Python is running sandboxed (UWP), the kernel specs are NOT located in %APPDATA%\... (as reported by jupyter kernelspec list), but in the redirected location %LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\...

The call to fs.fileExists therefore returns false, resulting in a few messages like Kernel not created with the name python38264bitbb49e9738bee4bad94750749010b815e, display_name Python 3.8.2 64-bit. Output is Installed kernelspec python38264bitbb49e9738bee4bad94750749010b815e in C:\Users\stroy\AppData\Roaming\jupyter\kernels\python38264bitbb49e9738bee4bad94750749010b815e

Expected behavior

  • Jupyter selects the existing python kernel and runs the code

Workaround

  • Add an environment variable called JUPYTER_DATA_DIR, which points to the redirected AppData folder (à la C:\Users\<User>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Roaming\jupyter).

Your Jupyter and/or Python environment

  • Jupyter server running: Local
  • Extension version: 2020.5.0-dev
  • VS Code version: 1.44.2
  • Setting python.jediEnabled: true
  • Python and/or Anaconda version: 3.8.2 (Microsoft Store version)
  • OS: Windows 10 1909
  • Virtual environment: N/A

Developer Tools Console Output

console.log

Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 19 (8 by maintainers)

Most upvoted comments

I found a better way: Add environment variable JUPYTER_DATA_DIR=C:\Users\[username]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_[random]\LocalCache\Roaming\jupyter and work like a charm.

Thanks for the feedback, we’ll add support for the Windows Store version.