Search code examples
jupyter-notebookanacondagoogle-colaboratoryprompt

Connecting Colab to Local Runtime Jupyter Notebook


I'm trying to connect my Google Colab to a local runtime via Jupyter Notebook. There is one part I can't figure out, which is this:

#Ensure that the notebook server on your machine is running on port 8888 and accepting requests from https://colab.research.google.com.
jupyter notebook \
  --NotebookApp.allow_origin='https://colab.research.google.com' \
  --port=8888 \
  --NotebookApp.port_retries=0

I tried copy-pasting it into my anaconda prompt but only "jupyter notebook " is pasted and executed. How do you get all that code typed into prompt? Is it some cmd feature that I'm completely oblivious to?


Solution

  • The command you are currently running should be run on a Linux machine. If you have a Windows machine, replace the \ at the end of each part of the command with ^. So, your command will be

    jupyter notebook ^
      --NotebookApp.allow_origin='https://colab.research.google.com' ^
      --port=8888 ^
      --NotebookApp.port_retries=0
    

    Or, the complete command with all the parameters can be run in a single line like this

    jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0
    

    I have tested this to work on the command prompt, and the local runtime connection is successful.