Ali Abdi
Ali Abdi

Reputation: 427

Open JupyterNotebook from VScode into the Browser

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?

Upvotes: 8

Views: 17938

Answers (4)

Justin Dehorty
Justin Dehorty

Reputation: 1716

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

Upvotes: 0

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.

Upvotes: 0

Gregory Somers
Gregory Somers

Reputation: 146

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

Upvotes: 9

guerda
guerda

Reputation: 24049

I do not have a solution, but only hints. You can let Code start a local server via Ctrl + Shift + P, then Jupyter connect , then select default.

Unfortunately, it's not documented how you can access the server. I gave that feedback on the documentation page.

enter image description here Source of the image: https://code.visualstudio.com/docs/python/jupyter-support#_connect-to-a-remote-jupyter-server

Upvotes: 1

Related Questions