Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Root access for Jupyter/iPython Notebook

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 run the notebook as root, but that only returns:

$ jupyter: 'notebook' is not a Jupyter command

So, I'm left with running $ jupyter notebook (unless there's a way to run Jupyter notebook as root).

I also can't do su root in the notebook itself because that requires an input and the notebook won't let me give an input.

Finally, there is allegedly an --allow-root option for Jupyter notebook: http://jupyter-notebook.readthedocs.io/en/latest/config.html

However, it looks like --allow_root is no longer an option. (I've tried modifying the config file by adding NotebookApp.allow_root=True, but that doesn't work.)

Any ideas guys? Maybe I'm doing something wrong?

like image 284
user42390 Avatar asked Jan 12 '17 21:01

user42390


4 Answers

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

jupyter notebook --allow-root
like image 153
An0n Avatar answered Nov 03 '22 05:11

An0n


The solution as described here. Is to use

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

Basically the binary to call jupyter notebook is in the user's PATH variable, but not for root.

Best regards.

like image 34
Imad Avatar answered Nov 03 '22 05:11

Imad


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.

like image 7
tiagohbalves Avatar answered Nov 03 '22 05:11

tiagohbalves


I am running the neopixel library from a jupyter notebook.

The only thing that worked for me was first running the "sudo su" command to move into the root environment and then run "jupyter notebook" (--allow-root alone didn't work for me).

like image 1
RCFuson Avatar answered Nov 03 '22 07:11

RCFuson