本地运行时404 GET

时间:2018-04-28 17:21:21

标签: google-colaboratory

我正在努力让谷歌协作本地运行时工作,但当我尝试连接到本地服务器时,我得到:

[I 10:17:23.142 NotebookApp] Serving notebooks from local directory: /home/adam/Documents/PYTHON/Complexity_Challenge/Spring_2018
[I 10:17:23.142 NotebookApp] 0 active kernels
[I 10:17:23.142 NotebookApp] The Jupyter Notebook is running at:
[I 10:17:23.142 NotebookApp] http://localhost:8891/
[I 10:17:23.142 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 10:17:33.609 NotebookApp] 404 GET /http_over_websocket (127.0.0.1) 50.27ms referer=None

404 GET就在最后一行。我按照https://research.google.com/colaboratory/local-runtimes.html

的要求更改了jupyter_notebook_config.py中的设置 编辑:在Bob的评论之后,我安装了软件包,然后打开笔记本电脑并尝试连接。它仍然无法正常工作,但错误信息不同:

(python3) adam@Rilke ~/Documents/DATA/terry20180313 $ jupyter serverextension enable --py jupyter_http_over_ws
Enabling: jupyter_http_over_ws
- Writing config: /home/adam/.jupyter
    - Validating...
      jupyter_http_over_ws  OK
(python3) adam@Rilke ~/Documents/DATA/terry20180313 $ 
(python3) adam@Rilke ~/Documents/DATA/terry20180313 $ jupyter notebook
[I 12:58:33.319 NotebookApp] The port 8888 is already in use, trying another port.
[I 12:58:33.320 NotebookApp] The port 8889 is already in use, trying another port.
[I 12:58:33.320 NotebookApp] The port 8890 is already in use, trying another port.
[I 12:58:33.321 NotebookApp] The port 8891 is already in use, trying another port.
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 12:58:33.341 NotebookApp] Serving notebooks from local directory: /home/adam/Documents/DATA/terry20180313
[I 12:58:33.341 NotebookApp] 0 active kernels
[I 12:58:33.341 NotebookApp] The Jupyter Notebook is running at:
[I 12:58:33.341 NotebookApp] http://localhost:8892/
[I 12:58:33.341 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[E 12:59:19.470 NotebookApp] Uncaught exception
    Traceback (most recent call last):
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/http1connection.py", line 238, in _read_message
        delegate.finish()
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/httpserver.py", line 289, in finish
        self.delegate.finish()
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/web.py", line 2047, in finish
        self.execute()
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/web.py", line 2067, in execute
        **self.handler_kwargs)
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/jupyter_http_over_ws/handlers.py", line 43, in __init__
        websocket.WebSocketHandler.__init__(self, *args, **kwargs)
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/websocket.py", line 127, in __init__
        super(WebSocketHandler, self).__init__(application, request, **kwargs)
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/web.py", line 185, in __init__
        self.clear()
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/web.py", line 289, in clear
        self.set_default_headers()
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/notebook/base/handlers.py", line 316, in set_default_headers
        self.set_header("Access-Control-Allow-Origin", self.allow_origin)
      File "/home/adam/anaconda2/envs/python3/lib/python3.4/site-packages/tornado/websocket.py", line 385, in _disallow_for_websocket
        if self.stream is None:
    AttributeError: 'HttpOverWebSocketHandler' object has no attribute 'stream'

3 个答案:

答案 0 :(得分:2)

该特定URL由Colab Jupyter扩展程序处理。你安装了吗?

pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws

(在启动Jupyter之前运行上面的命令。)

答案 1 :(得分:0)

确保已安装Colab“基于WebSocket的HTTP” Jupyter扩展(对于用户IUserService),并且版本高于0.0.7:

jupyter

通过WebSocket扩展启用Colab Jupyter HTTP:

pip install --upgrade jupyter_http_over_ws>=0.0.7

您可以使用以下命令来运行Jupyter:

jupyter serverextension enable --py jupyter_http_over_ws

答案 2 :(得分:0)

如果您使用 conda 安装环境,请尝试也通过 conda 安装 jupyter_http_over_ws 包:

conda install -c conda-forge jupyter_http_over_ws

然后您应该能够使用以下方法启用服务器扩展:

jupyter serverextension enable --py jupyter_http_over_ws

之后也在 PowerShell 中运行以下代码,您将在其中收到包含 Colab 令牌代码的 URL:

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' \ --port=9090 --no-browser
相关问题