解决jupyter “Running as root is not recommended.xxx”错误 && jupyter配置方法

1、问题解决

运行jupyter notebookjupyter 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的值。

在这里插入图片描述
refer:【Running a notebook server】

  • 13
    点赞
  • 56
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值