Google Colab中的“无法连接到本地运行时”

时间:2019-03-05 08:59:57

标签: google-colaboratory

我正在尝试连接本地运行时,但是没有连接,

我在以下命令中使用了故障排除对话框:

pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws

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

3 个答案:

答案 0 :(得分:2)

此问题在Colaboratory的github问题中提出: 这个答案帮助我https://github.com/googlecolab/jupyter_http_over_ws/issues/1#issuecomment-557469128

根据此问题

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --NotebookApp.port_retries=0 --notebook-dir="" --no-browser --allow-root --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True --port=8888

运行上述命令,然后转到

localhost:8888

然后重试使用Google Colab连接到本地运行时

如果不能解决您的问题,请尝试禁用AdBlock扩展程序或应用。

答案 1 :(得分:0)

本地连接可能失败的原因有很多。要收集更多诊断信息,请单击屏幕左下方显示的通知中的“疑难解答”链接。

它看起来像这样: enter image description here

我建议按照那里建议的任何步骤进行操作。如果遇到问题,请使用故障排除对话框中提供的诊断来更新您的原始问题。

答案 2 :(得分:0)

对于 Windows (10/11)

方法一:使用git bash

请按照以下步骤操作 https://research.google.com/colaboratory/local-runtimes.html

Using git bash

方法 2:使用 Windows 终端和多行命令

安装 jupyter_http_over_ws

pip install jupyter_http_over_ws

启用 jupyter_http_over_ws jupyter 扩展(一次性)

jupyter serverextension enable --py jupyter_http_over_ws

使用多行命令启动服务器并进行身份验证

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

Using mutilines & Windows terminal

方法 3:使用单行命令和 windows 终端

安装 jupyter_http_over_ws

pip install jupyter_http_over_ws

启用 jupyter_http_over_ws jupyter 扩展(一次性)

jupyter serverextension enable --py jupyter_http_over_ws

使用单行命令启动服务器并进行身份验证

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

Using Single line and windows terminal

一旦服务器启动,它将打印一条带有用于身份验证的初始后端 URL 的消息。复制此网址,因为您需要在下一步中提供该网址。

enter image description here

连接到本地运行时 在 Colaboratory 中,单击“连接”按钮并选择“连接到本地运行时...”。在出现的对话框中输入上一步中的 URL,然后单击“连接”按钮。在此之后,您现在应该连接到本地运行时。

enter image description here