oauth - JupyterHub - 未找到 oauth_client_id
问题描述
我正在使用 Azure 使用 Jupyterhub 运行 python 笔记本。启动 VM 后,我只需使用我的用户名和密码(就像 ssh 一样)就可以访问笔记本。但是,一天后,当我切换到另一个网络时(我并不是说网络可能有问题),我无法访问该链接。它给了我The site can't be reached
错误。
所以我尝试再次重新运行该过程,从那时起我一直在努力让它再次运行。我在 GitHub 上搜索过类似的问题,但它们也没有帮助。
在使用kill pid
命令杀死进程后,我尝试通过以下命令运行 jupyterhub:
/anaconda/envs/py35/bin/python /anaconda/envs/py35/bin/jupyterhub-singleuser --port=50387 --notebook-dir="~/notebooks" --config=/etc/jupyterhub/jupyterhub_config.py
它给了我错误:
JUPYTERHUB_API_TOKEN env is required to run jupyterhub-singleuser. Did you launch it manually?
所以我搜索了与此类似的github问题。我尝试使用以下方法手动生成令牌:
jupyterhub token username
我通过export JUPYTERHUB_API_TOKEN=token
. 我还在 jupyterhub_config.py 的 c.Authenticator.tokens 中添加了 token:username。现在我得到这个错误:
Traceback (most recent call last):
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/traitlets.py", line 528, in get
value = obj._trait_values[self.name]
KeyError: 'oauth_client_id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda/envs/py35/bin/jupyterhub-singleuser", line 6, in <module>
main()
File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyterhub/singleuser.py", line 455, in main
return SingleUserNotebookApp.launch_instance(argv)
File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/anaconda/envs/py35/lib/python3.5/site-packages/notebook/notebookapp.py", line 1296, in initialize
self.init_webapp()
File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyterhub/singleuser.py", line 393, in init_webapp
self.init_hub_auth()
File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyterhub/singleuser.py", line 388, in init_hub_auth
if not self.hub_auth.oauth_client_id:
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/traitlets.py", line 556, in __get__
return self.get(obj, cls)
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/traitlets.py", line 535, in get
value = self._validate(obj, dynamic_default())
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/traitlets.py", line 593, in _validate
value = self._cross_validate(obj, value)
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/traitlets.py", line 599, in _cross_validate
value = obj._trait_validators[self.name](obj, proposal)
File "/anaconda/envs/py35/lib/python3.5/site-packages/traitlets/traitlets.py", line 907, in __call__
return self.func(*args, **kwargs)
File "/anaconda/envs/py35/lib/python3.5/site-packages/jupyterhub/services/auth.py", line 439, in _ensure_not_empty
raise ValueError("%s cannot be empty." % proposal.trait.name)
ValueError: oauth_client_id cannot be empty.
我不确定我在这个过程中哪里出错了。有人熟悉这个问题吗?
解决方案
尝试运行jupyterhub
而不是jupyterhub-singleuser
针对您的特定用例,命令如下:
sudo /anaconda/envs/py35/bin/python /anaconda/envs/py35/bin/jupyterhub --port=50387 --notebook-dir="~/notebooks" --config=/etc/jupyterhub/jupyterhub_config.py
确保 jupyterhub 安装(正确)在您提到的路径中。
推荐阅读
- flutter - 如何扩展 BorderSide 以制作渐变边框
- google-apps-script - 如何根据条件更新不同选项卡上的单元格值
- python - R 交互()函数的 Python 等效项
- javascript - 如何在 Mapbox-gl-js 中为特定案例创建表达式?
- c# - 将 WCF 服务访问限制为仅使用控制台应用程序托管的 localhost
- react-native - 如何在本机反应中将项目高度设置为等于 FlatList 高度?
- r - 如何为具有不同 x 值的线图添加标记
- javascript - 为什么 JSON.stringify() 对于大型对象来说很慢
- firefox - 将向量数组传递给着色器
- python - 存储和处理串行数据时的问题