Root access for Jupyter/iPython Notebook

前端 未结 8 1197
遇见更好的自我
遇见更好的自我 2021-02-07 13:50

I\'m trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself.

I\'ve tried $ sudo jupyter notebook to ru

相关标签:
8条回答
  • 2021-02-07 13:57

    Just login as root, then do the following command to start the notebook :

    jupyter notebook --allow-root
    
    0 讨论(0)
  • 2021-02-07 14:00

    Generate config

    root@user# jupyter notebook --generate-config

    root/.jupyter/jupyter_notebook_config.py root@user# cd .jupyter/ root@user:/.jupyter/# gedit jupyter_notebook_config.py Add line in jupyter_notebook_config.py

    c.NotebookApp.allow_root=True

    0 讨论(0)
  • 2021-02-07 14:02

    Add c.NotebookApp.allow_root=True from the root configuration files. That you don't need ask to allow-rootevery time then you start the notebook.

    Edit:

    Before edit the configuration file you need to run jupyter notebook --generate-config as root to make the file.

    0 讨论(0)
  • 2021-02-07 14:07

    When I need to execute command as root in my notebook, I use the -A flag, that allows to access an helper program used to read the user's password when no terminal is available. You need to modify the sudo.conf file before to declare the helper program. On a Debian Buster, I personnaly added:

    Path askpass: /usr/libexec/seahorse/ssh-askpass

    See the main page of sudo.conf for more information.

    0 讨论(0)
  • 2021-02-07 14:08

    You should try running the command sudo jupyter notebook --allow-root , I'm not sure why but this works. On the server it'll ask you for a password, if you have set up a password for it just type it in the box that will be shown, otherwise, type jupyter notebook password to set up a new password

    0 讨论(0)
  • 2021-02-07 14:08

    In case anyone is still looking for an answer, this is what worked for me:

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

    Switching user using su didn't work because I didn't have jupyter installed on root. Using just --allow-root by itself also didn't work for me. This allows you to run sudo with jupyter notebook without running into the issue of "notebook" not being a valid command. Because I am using a linux terminal, jupyter-notebook is installed at ~/.local/bin/jupyter-notebook. See After installing with pip, "jupyter: command not found" for more information about where jupyter may be installed.

    0 讨论(0)
提交回复
热议问题