简体   繁体   中英

VS Code Jupyter Extension: Remote notebook not starting

I'm trying to connect to a remote Jupyter notebook using the VS Code Jupyter extension.

Afterwards an input field asking for the token is shown. When I enter the token and press Enter<\/kbd> , nothing happens.

Using a notebook hosted on localhost:8888<\/code> and well an notebook hosted on a different computer within my home network 192.168.0.11:8888<\/code> . Both ways do not work.

If I do not start VS Code within a Python environment with jupyter<\/code> installed, I am not able to run any notebooks (but this seems to be an know issue).

(If yes, how?)

使用以下命令:

jupyter notebook --ip=0.0.0.0 --port=8080 --allow-root

At first glance, it would appear that you got the token incorrect. When I chose the option to enter the Url of a remote server and got the token wrong, the only indication things weren't working was the fact that I couldn't execute any Python code. And, when I used that same Url in a browser, I got a web UI that asked me to enter a token. Once I found and entered a valid token, I got their nice little UI for working in notebooks.

As for my experience, I just got it working in VsCode a few moments ago: I have a .ipynb file open in VsCode, it's switched to being pointed at my remote Jupyter Server, and I can execute code against it and get output.

Overview of my setup

Prerequisites

  1. I have VsCode setup with the Python, Pylance, Jupyter, Jupyter Keymap, and Jupyter Notebook Renderers extensions. I did these as part of my initial forays into Python and then using Jupyter Notebooks.
    • While I've been able to use Jupyter Notebooks and have autocomplete/Intellisense working against my local machine, I don't know enough to say which extensions are required for this, nor if there's some setup I did as part of that which is critical for this remote setup to work.
  2. I'm on a Windows 10 box and have WSL2 setup with a Ubuntu image and Docker is installed and setup within it.

The steps

  1. Install a docker image that has Spark, Python, PySpark, and Jupyter all setup for you: docker run -d --name jspark -p 8888:8888 jupyter/pyspark-notebook
  2. Get the auth token: docker exec -it jspark jupyter server list
  3. Get the IP address of eth0 : ip addr
  4. Using the output of the previous 2 steps, build the final URL that you can use from the host (Windows) OS to connect to the Jupyter server.
  5. Prove it works by navigating to it in a browser.
  6. Over in VsCode, use that same URL as the location of the remote Jupyter Server.

If everything goes as expected, VsCode will "think" for a bit while it tests the connection, and then you'll see that "play" button show up to the left of your Python cell(s).

I used this code to prove it was working:

from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
df = spark.read.json("/usr/local/spark/examples/src/main/resources/people.json")
df.show()

And now I can move on to improving the experience, since I have a known working baseline. I'm hoping to get autocomplete/Intellisense working, but based on what I've read so far, I'm not holding my breath.

The problem I encountered is as follows

command 'jupyter.selectExistingNotebook' not found

I installed the Jupyter extension on vscode. Follow the instructions: Remote Jupyter kernel on Server / Docker

Try this to connect to a remote Jupyter kernel running on a server, or inside Docker container:

Start a remote Jupyter Notebook or headless KernelGateway

Find the token in the output of the Jupyter server logs: http://jupyter-notebook.readthedocs.io/en/latest/security.html

Then in VS Code: ctrl+shift+p

Jupyter: Enter the url of local/remote Jupyter Notebook

I only installed docker and run the container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM