从外部访问Jupyter笔记本-如何允许Google Colab访问本地主机Jupyter笔记本? [英] Access to Jupyter notebook from outside - How to allow google colab to access a local host Jupyter notebook?

查看:208
本文介绍了从外部访问Jupyter笔记本-如何允许Google Colab访问本地主机Jupyter笔记本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从google colab连接到本地主机-它不起作用,谷歌故障排除建议建议,我应该允许本地Jupyter笔记本接受colab请求-怎么做?

I am trying to connect from google colab to local host - it does not work, google troubleshooting advise suggests that I should allow local Jupyter notebook to accept colab requests - how to do it ?

来自本地主机的屏幕快照,用于确认禁止来自colab的请求.应该进行一些配置修改以允许此类请求,不是吗?

Screenshot from local host which confirms that requests from colab are forbidden. There should be some config modification to allow such requests, is not it ?

colab的建议:

Advise from colab:

推荐答案

我如何解决连接问题:

如果上述命令无效,最后对我来说是为端口8888创建防火墙规则.

命令行中的说明中有另一个很大的提示,但是在提供的Google教程中没有提到,有些人会想念的是,您需要在启动Jupyter之后打开在给您的浏览器中提供的URL.创建访问Cookie并使其有效(可以说).

Another big one that is in the instructions in your command line but not stated on the provided Google tutorial that some people will miss is that you need to open the URL in your browser that's given to you after launching Jupyter in order for it to create the access cookie and make it valid (sort of speak).

在提供的屏幕截图中,确保您具有"http://localhost:8888/?token = 2534 ..."在您使用允许访问colab的相同帐户登录的浏览器中打开浏览器(在运行命令时,通常会弹出一个单独的窗口或选项卡).

From the screenshot you provided, make sure you have "http://localhost:8888/?token=2534..." opened in your browser that is logged in with the same account accessing colab before it will allow access to colab (a separate window or tab will usually pops up on it's own when you run the command though).

或者,您也可以添加-no-browser 标记,以防止需要在浏览器中打开它

Alternatively, you can also add the --no-browser tag to prevent the need to open it in your browser

我还有一些其他的故障排除步骤,但是我不知道是否适用于您,但是在安装Jupyter时是否遇到任何问题?对我来说,即使jupyter仍然可以启动,但在Windows上安装时还是有错误,并且要修复这些错误,我必须用pipwin替换pip并按照这种方式进行操作.

There were a number of other troubleshooting steps that were particular to me but dont know if will apply to you but did you have any issues when installing Jupyter? For me, even though jupyter would still launch, there were errors when installing on Windows, and to fix those I had to replace pip with pipwin and go through the steps that way.

例如

pipwin install jupyterlabs
pipwin install jupyter_http_over_ws

以防万一它可以帮助将来遇到的其他任何人,如果您使用的是DOS cmd系列,并且在启动jupyter时遇到问题,请替换".带有"^"表示继续

And in case it helps anyone else coming across this in the future, if you're using the DOS cmd line and have issues launching jupyter, replace the "" with a "^" to indicate continuation

即:

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

这篇关于从外部访问Jupyter笔记本-如何允许Google Colab访问本地主机Jupyter笔记本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆