12

I want to use Jupyter Notebooks inside VS Code running within WSL 2. Regular Python works within WSL without a problem, that means the base conda enviroment is connected and I can run .py files. Moreover, I’m able to run the command jupyter notebook which will start the notebook server within WSL exposing the localhost to the Windows system.

However, I want to test the new Jupyter Notebook feature within VS Code, which is not working for me; VS Code shows: Jupyter Server: No Kernel and Python: Not Started (see screenshot below).

My testing machine is:

  • WSL 2 (using Pengwin distribution) on Windows 20H1 (19041.21)
  • VS Code 1.41 (having the Python extension installed)
  • Anaconda

What I did:

  1. Open WSL
  2. Open VS Code in my target directory (code .)
  3. Create a new Notebook file from the command palette Python: Create New Blank Jupyter Notebook
  4. Create dummy print("test")
  5. Run Cell will trigger the warning:

enter image description here

Is there anything I’m missing?

5
  • Did you set the server URI? Looks like the URI is too short. You set it with the 'Python: Specify local or remote Jupyter server for connections'. You should pick default if you haven't already
    – R Chiodo
    Feb 5, 2020 at 16:46
  • As you are using Windows Insider Build, it has many issue associated with accessing localhost. See this as example github.com/microsoft/WSL/issues/4353.
    – Biswapriyo
    Feb 8, 2020 at 7:21
  • 1
    Humn, it is actually working now, yet I don’t know what fixed it...
    – Kalaschnik
    Feb 9, 2020 at 18:55
  • 3
    Any new info for this? Now that WSL2 is released to stable, I'm still having the issue the OP mentioned Jun 11, 2020 at 0:12
  • I'm having this issue on wsl2 as well. EDIT: it's working now. not sure why, i didn't change anything.
    – jshen
    Jun 26, 2020 at 4:00

3 Answers 3

4

The VSCode extensions on the windows side and the WSL side are independent of each other, and you need to install the python extension on the WSL side.

VSCode will prompt you to install them when you run .py file on the WSL side, but running .ipynb will not. This is probably the source of the problem.

0
3

The VS Code insiders actually works out of box with Jupyter notebooks. Just remember to run code-insiders . instead of code ..

Another solution would be, according to this website, start the VS Code in windows, then use WSL 2 as a remote server.

1

The code installation on wsl2 needs a restart to work properly, I was told by a notification, and in the question's comments you may see people experiencing the same issue(' it's working now. not sure why'). So before looking upon any elaborate solution, just restart code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.