1、问题解决
运行jupyter notebook
、jupyter lab
出现“Running as root is not recommended. Use --allow-root to bypass”错误
可以通过如下方法解决该问题:
1-1、产生jupyter配置文件
使用 jupyter notebook --generate-config
命令生成jupyter配置文件,将会提示当前生成的配置文件的存放路径,一般为 ~/.jupyter/jupyter_notebook_config.py
1-2、修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py
打开配置文件,找到 #c.NotebookApp.allow_root = False
,去掉#,并修改为True。
保存该文件,使用jupyter notebook
重新运行程序。
关于后台运行jupyter, 可以参考另一片文章:后台运行jupyter notebook程序
2、jupyter配置
-
使用jupyter notebook,更推荐使用 jupyter lab,这样有浏览操作的功能,非常便捷。安装方法:
pip3 install jupyterlab
或者pip install jupyterlab
。 -
如果只是临时性使用,推荐如下命令运行jupyter:
jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser
-
永久有效的配制方法,配置文件产生方法见:上面1-1的方法:
- 使用
jupyter notebook --generate-config
命令生成jupyter配置文件 - 使用
vim ~/.jupyter/jupyter_notebook_config.py
打开配置文件,找到或者直接添加如下内容修改相关配置
c.NotebookApp.ip = '0.0.0.0' # listen on all IPs,远程访问时需要配置该项 c.NotebookApp.port = 55555 #jupyter监听的端口 c.NotebookApp.open_browser = False #是否在键入`jupyter`时打开浏览器 c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$yquzhGfZQd0ul/9aC4F7cQ$qMZffPLzgtukdg51uY6+aQ' #jupyter server密码,生成方法见3的内容。 c.NotebookApp.allow_root = False #是否同意jupyter以root身份运行
- 使用
3、jupyter修改密码
- 终端中键入
jupyter notebook password
命令,输入密码,生成的密码将会保存在~/.jupyter/jupyter_notebook_config.json
文件中。如下图中1所示 - 使用
cat ~/.jupyter/jupyter_notebook_config.json
查看文件内容,将其中password内容提取出来,修改配置文件c.NotebookApp.password
的值。