9

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?

Kalaschnik
  • 769
  • 1
  • 7
  • 21
  • 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 05 '20 at 16:46
  • As you are using Windows Insider Build, it has [many issue](https://github.com/microsoft/WSL/search?q=localhost&type=Issues) associated with accessing localhost. See this as example https://github.com/microsoft/WSL/issues/4353. – Biswapriyo Feb 08 '20 at 07:21
  • 1
    Humn, it is actually working now, yet I don’t know what fixed it... – Kalaschnik Feb 09 '20 at 18:55
  • 2
    Any new info for this? Now that WSL2 is released to stable, I'm still having the issue the OP mentioned – Jhirschibar Jun 11 '20 at 00: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 '20 at 04:00

3 Answers3

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.

3

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.

Yellow
  • 31
  • 5
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.