linux - 使用 Google Colab 连接 Jupyter 笔记本时出现 "Forbidden"错误

标签 linux jupyter-notebook google-colaboratory

因此,我尝试按照 Google 的说明将 Google Colab 链接到安装在我的 Linux (ubuntu) 计算机上的 Jupyter 笔记本:https://research.google.com/colaboratory/local-runtimes.html

笔记本服务器启动正常,但是当通过 Google Colab 连接到它时,连接失败,并收到“禁止”错误。

(base) my_user@sysmain:~$ jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0 --no-browser
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 23:01:03.636 NotebookApp] JupyterLab extension loaded from /home/my_user/miniconda3/lib/python3.8/site-packages/jupyterlab
[I 23:01:03.636 NotebookApp] JupyterLab application directory is /home/my_user/miniconda3/share/jupyter/lab
[I 23:01:03.638 NotebookApp] Serving notebooks from local directory: /home/my_user
[I 23:01:03.638 NotebookApp] Jupyter Notebook 6.1.3 is running at:
[I 23:01:03.638 NotebookApp] http://localhost:8888/
[I 23:01:03.638 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 23:01:20.212 NotebookApp] 302 GET / (127.0.0.1) 0.68ms
[I 23:01:20.214 NotebookApp] 302 GET /tree (127.0.0.1) 0.45ms
[W 23:01:20.240 NotebookApp] Forbidden
[W 23:01:20.240 NotebookApp] 403 GET /api/kernelspecs (127.0.0.1) 0.56ms referer=None
[I 23:01:22.273 NotebookApp] 302 GET / (127.0.0.1) 0.29ms
[I 23:01:22.274 NotebookApp] 302 GET /tree (127.0.0.1) 0.40ms
[W 23:01:22.278 NotebookApp] Forbidden
[W 23:01:22.278 NotebookApp] 403 GET /api/kernelspecs (127.0.0.1) 0.48ms referer=None

之前有过关于此主题的帖子 ( https://github.com/googlecolab/colabtools/issues/162 ),但是添加 --no-browser 并没有解决问题,正如您通过我输入的命令看到的那样。

感谢您的帮助!

最佳答案

我在 ~/.jupyter/jupyter_notebook_config.py 中配置 jupyter 进行密码身份验证后遇到了这个问题。注释掉这些行

c.NotebookApp.password
c.NotebookApp.password_required

关闭密码并导致 Jupyter 使用基于 token 的身份验证。或者,如果您添加这样的行

c.NotebookApp.token = 'yourTokenValue'

然后您可以通过 http://localhost:PORT/?token=yourTokenValue 连接

关于linux - 使用 Google Colab 连接 Jupyter 笔记本时出现 "Forbidden"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63555815/

相关文章:

linux - 如何检测子模块中父 Git 存储库的正确 GIT_DIR 和 GIT_WORK_TREE

java - 使用 netbeans 项目在 Linux 中构建无法工作

amazon-web-services - 在 AWS EC2 实例上托管 Jupyter Notebook 时无法获得可信连接

google-colaboratory - 使用 google colab 安装 google drive 而不每次都询问授权码

settings - 更改 Google Colab 语言设置

linux - 在 bash 配置文件中编写函数,从终端调用

linux - docker 容器大小远大于实际大小

ipython - 可以在jupyter单元函数上运行python doctest吗?

android - Android 上使用 Termux 的 Jupyter 笔记本无法上传文件和识别目录

python - Google Colab 中的交互式 matplotlib 图