jupyter-notebook - 无法以 root 身份启动笔记本
问题描述
我正在尝试以 root 用户身份在 Jupyter notebook 中运行 pyspark。我通过编辑 /root/.jupyter/jupyter_notebook_config.py 为笔记本启用了 root 访问权限。我还编辑了 bashrc 文件,如https://blog.sicara.com/get-started-pyspark-jupyter-guide-tutorial-ae2fe84f594f部分方法 1 — 配置 PySpark 驱动程序中所述。但是,在尝试以 root 身份运行 pyspark 时,我得到了
xdg-open:没有可用于打开“file:///root/.local/share/jupyter/runtime/nbserver-20051-open.html”的方法
# pyspark
[I 17:12:15.544 NotebookApp] Serving notebooks from local directory: /home/applied
[I 17:12:15.544 NotebookApp] The Jupyter Notebook is running at:
[I 17:12:15.544 NotebookApp] http://localhost:8888/?token=c5408eb73daf9b0c7c3a92418b69e128d01b1c11a8ed8d75
[I 17:12:15.544 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:12:15.553 NotebookApp]
To access the notebook, open this file in a browser:
file:///root/.local/share/jupyter/runtime/nbserver-20384-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=c5408eb73daf9b0c7c3a92418b69e128d01b1c11a8ed8d75
Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /home/applied/.Xauthority which is owned by applied.)
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/run-mailcap line 528.
[20515:20515:0612/171215.882932:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
Warning: program returned non-zero exit code #1
Opening "/root/.local/share/jupyter/runtime/nbserver-20384-open.html" with Firefox Web Browser (text/html)
Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /home/applied/.Xauthority which is owned by applied.)
[20586:20586:0612/171216.094968:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /home/applied/.Xauthority which is owned by applied.)
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: mozilla: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: epiphany: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: chromium-browser: not found
[20614:20614:0612/171216.184980:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'file:///root/.local/share/jupyter/runtime/nbserver-20384-open.html'
解决方案
升级系统后,我遇到了类似的问题。该错误指定不应以 root 模式打开 Firefox,但如果sudo
未使用,则会jupyter notebook
引发权限被拒绝错误。我解决了它——虽然我自己对解决方案不是很满意——通过递归地更改以下权限:
~/.local/share/jupyter/runtime/*
所以基本上,我更改了.local
, then./local/share
等的权限,一直到运行时的内容。然后,当我在终端中运行jupyter notebook
(注意,sudo
这里没有)时,它起作用了。
不过,还有另一种解决方案。正如终端窗口所说,您可以手动将指定的 URL 复制并粘贴到首选浏览器中。但这每次都必须手动完成。
PS 我的系统是一台运行 Ubuntu 18.04 的个人笔记本电脑。
推荐阅读
- javascript - 在存储在变量中的组件中传递道具
- python - 根据是否每天输入,将输入日志 (csv) 转换为名称列表
- javascript - TypeError:无法读取未定义的属性“charCodeAt” - 按钮有时不起作用
- rest - 我们如何将 REST 和 RPC 用作集成框架?
- amazon-emr - 如何将 livy 解释器添加到在 EMR 集群上运行的 Zeppelin
- linker - LLVM 链接:命令行错误:选项“帮助列表”注册了多次!LLVM 错误:注册的命令行选项不一致
- php - PHP在字符串中显示浮点数
- c++ - 在 QT 中包含 QtSql 库时出现“运算符不匹配”
- ssl - Running Go server behind Nginx Reverse Proxy with SSL
- python - 有什么方法可以使用 python regex 在目录和子目录的所有文件中搜索?