美文网首页
Ubantu18.04.6 配置jupyter notebook

Ubantu18.04.6 配置jupyter notebook

作者: Aji | 来源:发表于2022-03-02 15:21 被阅读0次

一.安装

1.使用conda 安装

conda install jupyter notebook

二.配置文件

1.生成配置文件

jupyter notebook --generate-config

2. 生成密钥

这里有两种方法

先说第一种:使用password指令生成密钥,生成的密钥在一个文件里

jupyter notebook password

第二种方法:在python环境中生成密钥

ipython
from notebook.auth import passwd
passwd()

会生成一组密钥sha1:*********:*******************这种格式
我使用第一种方法
结果如下


密钥

文件名字叫做
/home/用户/.jupyter/jupyter_notebook_config.json

cat /home/用户/.jupyter/jupyter_notebook_config.json

{
  "NotebookApp": {
    "password": "sha1:*(一串数字)"
  }

3.修好配置文件

vi  /home/用户/.jupyter/jupyter_notebook_config.py

在该文件中做如下修改或直接在文件尾端添加:

c.NotebookApp.ip='*'    # 允许所有ip访问
c.NotebookApp.password = u'sha:ce...' # 第2步复制的密钥(注意第一个单引号前加小写u)
c.NotebookApp.open_browser = False  # 可改可不改 默认打开浏览器
c.NotebookApp.port =8888        #外部连接的端口
c.NotebookApp.allow_remote_access = True  # 不改就报错,被坑了一下午
## The default URL to redirect to from `/`
#添加存储路径
c.NotebookApp.default_url = '路径'

4.服务器上挂在后台上用

nohup jupyter notebook >~/jupyter.log 2>&1 &

这边的话我的端口老是会被占据
所以我一般会看jupyter.log 文件中的端口号

image.png

5.浏览器上打开

ip:端口号


配置成功,开心

参考: https://www.jianshu.com/p/3cc167bd63dd
https://www.cnblogs.com/bugcreator/p/11178382.html
https://www.cnblogs.com/xbhog/p/13610741.html

相关文章

网友评论

      本文标题:Ubantu18.04.6 配置jupyter notebook

      本文链接:https://www.haomeiwen.com/subject/bdzsrrtx.html