【问题标题】:Root access for Jupyter/iPython NotebookJupyter/iPython Notebook 的根访问权限
【发布时间】:2017-05-28 03:20:47
【问题描述】:

我正在尝试在 iPython/Jupyter 笔记本中使用 bash 内核,但我需要在笔记本本身中进行 sudo 访问。

我已经尝试$ sudo jupyter notebook 以 root 身份运行笔记本,但这只会返回:

$ jupyter: 'notebook' is not a Jupyter command

所以,我只能运行 $ jupyter notebook(除非有办法以 root 身份运行 Jupyter notebook)。

我也不能在笔记本本身中执行su root,因为这需要输入,而笔记本不允许我输入。

最后,据称 Jupyter 笔记本有一个 --allow-root 选项: http://jupyter-notebook.readthedocs.io/en/latest/config.html

但是,--allow_root 似乎不再是一个选项。 (我尝试通过添加NotebookApp.allow_root=True 来修改配置文件,但这不起作用。)

有什么想法吗?也许我做错了什么?

【问题讨论】:

  • 这里有同样的问题。无法在 jupyter notebook 中使用 snap.py
  • 还在等待解决方案...?

标签: bash ipython ipython-notebook jupyter-notebook


【解决方案1】:

只需以root身份登录,然后执行以下命令即可启动笔记本:

jupyter notebook --allow-root

【讨论】:

    【解决方案2】:

    here 描述的解决方案。是使用

    sudo -E env "PATH=$PATH" jupyter notebook
    

    基本上,调用jupyter notebook 的二进制文件在用户的PATH 变量中,但不适用于root。

    最好的问候。

    【讨论】:

    • *****这才是真正解决这个问题的方法!!
    • 你拯救了我的一天
    【解决方案3】:

    从根配置文件中添加c.NotebookApp.allow_root=True。无需每次启动笔记本时都询问allow-root

    编辑:

    在编辑配置文件之前,您需要以 root 身份运行 jupyter notebook --generate-config 来生成文件。

    【讨论】:

    • 这个配置文件在哪里..?
    • Aetos 的配置文件是在命令之后生成的:$sudo jupyter notebook --generate-configjupyter notebook --generate-config 作为 root,将返回本地文件。
    【解决方案4】:

    我正在从 jupyter notebook 运行 neopixel 库。

    唯一对我有用的是首先运行“sudo su”命令进入根环境,然后运行“jupyter notebook”(单独的--allow-root 对我不起作用)。

    【讨论】:

      【解决方案5】:

      您应该尝试运行命令 sudo jupyter notebook --allow-root ,我不知道为什么,但这有效。在服务器上它会要求您输入密码,如果您为其设置了密码,只需在将显示的框中输入,否则,输入 jupyter notebook 密码以设置新密码

      【讨论】:

        【解决方案6】:

        生成配置

        root@user# jupyter notebook --generate-config

        root/.jupyter/jupyter_notebook_config.py root@user# cd .jupyter/ root@user:/.jupyter/# gedit jupyter_notebook_config.py 在 jupyter_notebook_config.py 中添加一行

        c.NotebookApp.allow_root=True

        【讨论】:

        • 您能进一步解释您的解决方案吗?
        【解决方案7】:

        当我需要在笔记本中以 root 身份执行命令时,我使用-A 标志,它允许在没有可用终端时访问用于读取用户密码的帮助程序。 在声明帮助程序之前,您需要修改sudo.conf 文件。在 Debian Buster 上,我个人添加了:

        路径询问/usr/libexec/seahorse/ssh-askpass

        更多信息请参见sudo.conf的主页。

        【讨论】:

          【解决方案8】:

          如果有人仍在寻找答案,这对我有用:

          sudo ~/.local/bin/jupyter-notebook --allow-root
          

          使用 su 切换用户不起作用,因为我没有在 root 上安装 jupyter。仅使用 --allow-root 本身对我也不起作用。这允许您使用 jupyter notebook 运行 sudo,而不会遇到“notebook”不是有效命令的问题。因为我使用的是linux终端,所以jupyter-notebook安装在~/.local/bin/jupyter-notebook。有关可以安装 jupyter 的位置的更多信息,请参阅 After installing with pip, "jupyter: command not found"

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2016-06-23
            • 1970-01-01
            • 1970-01-01
            • 2021-07-12
            • 2017-09-23
            • 2023-03-10
            • 1970-01-01
            • 2020-02-24
            相关资源
            最近更新 更多