谷歌colab中“无法连接到本地运行时”

sag*_*cis 6 anaconda jupyter-notebook 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
Run Code Online (Sandbox Code Playgroud)

已尝试与以下 URL https://research.google.com/colaboratory/local-runtimes.html中所述相同的上述步骤

遇到问题“未检测到 Jupyter 身份验证 cookie”尝试禁用广告拦截器、防病毒软件并使用不同的端口号。以下是团队给出的解决方案

在单独的浏览器选项卡中导航到http://localhost:8888并按照提供的说明进行操作。这将设置一个浏览器 cookie,用于浏览器和 Jupyter 笔记本服务器之间的身份验证。

但是当我打开 URL 时,它会要求输入密码(已设置),然后不会出现进一步的说明。

Ahw*_*war 7

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

根据这个问题

使用以下命令启动 jupyter 笔记本。

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
Run Code Online (Sandbox Code Playgroud)

然后通过访问此 URL 打开笔记本。

localhost:8888
Run Code Online (Sandbox Code Playgroud)

根据kris 的说法,这可能允许您连接,但它基本上禁用了所有安全功能。

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

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


Loj*_*uka 5

对于 Windows (10/11)

方法一:使用git bash

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

使用 git bash

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

安装 jupyter_http_over_ws

pip install jupyter_http_over_ws
Run Code Online (Sandbox Code Playgroud)

启用 jupyter_http_over_ws jupyter 扩展(一次性)

jupyter serverextension enable --py jupyter_http_over_ws
Run Code Online (Sandbox Code Playgroud)

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

jupyter notebook ^
  --NotebookApp.allow_origin='https://colab.research.google.com' ^
  --port=8888 ^
  --NotebookApp.port_retries=0
Run Code Online (Sandbox Code Playgroud)

使用多行和 Windows 终端

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

安装 jupyter_http_over_ws

pip install jupyter_http_over_ws
Run Code Online (Sandbox Code Playgroud)

启用 jupyter_http_over_ws jupyter 扩展(一次性)

jupyter serverextension enable --py jupyter_http_over_ws
Run Code Online (Sandbox Code Playgroud)

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

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0
Run Code Online (Sandbox Code Playgroud)

使用单行和 Windows 终端

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

在此输入图像描述

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

在此输入图像描述


Bob*_*ith 0

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

它看起来像这样: 在此输入图像描述

我建议遵循那里推荐的任何步骤。如果您遇到困难,请使用故障排除对话框中提供的诊断更新您的原始问题。