【问题标题】:How to start a notebook server in Jupyter Hub using its REST APIs?如何使用其 REST API 在 Jupyter Hub 中启动笔记本服务器?
【发布时间】:2019-05-28 11:29:43
【问题描述】:

我想按照here 的描述在我的 Jupyter Hub 上启动笔记本服务器并开始使用,即使我遵循的基本命令也不起作用。我想使用我提到的here 的令牌发出正常请求。 我的代码是:

import requests
token = "aa36d53a8cb5473a9e7ee07b1f3d8a49"
api_url = 'http://<some_no>.ap-south-1.elb.amazonaws.com/hub/api'
r = requests.get(api_url + '/users', headers={ 'Authorization': 'token %s' % token, } )
r.raise_for_status()

那么,我面临一个错误,其回溯是:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://<some_no>.ap-south-1.elb.amazonaws.com/hub/api/users

注意:我已按照official doc 中的说明生成了令牌。我还在我的 config.yaml 文件中添加了 Jupyter Hub 不时声明的相同内容。

我无法在这种无礼的文档中找出正确的方法。

【问题讨论】:

    标签: python python-requests jupyter-notebook jupyter jupyterhub


    【解决方案1】:

    您的实例防火墙配置可能有问题?您是否启用 HTTP/HTTPS 流量?

    要检查 api 是否正常工作,您可以使用不需要身份验证的端点:http://&lt;some-ip&gt;/hup/api 它应该返回 JupyterHub 版本。

    【讨论】:

      猜你喜欢
      • 2021-10-06
      • 1970-01-01
      • 2019-10-19
      • 1970-01-01
      • 2020-01-24
      • 2021-04-14
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多