Open JupyterNotebook from VScode into the Browser

Viewed 4287

I have opened my .ipynb file with vscode (Python 3.9 Interpreter - installed jupyterlab), it's connected locally, how can I open it through the browser? what is the default port?

4 Answers

Type: jupyter notebook in vscode terminal (Ctrl + Shift + ~) and it will start Jupyter in browser of your preference.

If jupyter not installed type: pip install jupyter in elevated powershell or however you prefer to do installs.

If pip not installed: python -m pip install -U pip

if python not installed I prefer to install with chocolatey and walkthrough is on their site. https://docs.python-guide.org/starting/install3/win/#install3-windows

You can list all running notebooks and their tokens by typing jupyter notebook list in the terminal.
It will output something like this:

Currently running servers:
http://localhost:8889/?token=your_token :: /directory

You can click on the link to open it in the browser.

A solution for CORS-related issues:

In my case, the problem was in my CORS configuration. What fixed it for me was launching the notebook from the terminal with the allowed origin specified:

jupyter notebook --no-browser --NotebookApp.allow_origin_pat=https://.*vscode-cdn\.net

If, for some reason, that doesn't work, you could try the following as a last resort (bearing in mind this will allow ANY origin):

jupyter notebook --no-browser --NotebookApp.allow_origin='*'

Source:

https://github.com/microsoft/vscode-jupyter/wiki/Connecting-to-a-remote-Jupyter-server-from-vscode.dev

Related