更新时间:2024-10-11 GMT+08:00

安装Jupyter Notebook

  1. 使用root用户登录客户端节点,执行如下命令安装Jupyter Notebook。

    pip3 install jupyter notebook

    显示结果如下,表示安装成功:

  2. 为了安全,我们需要生成一个密文密码用于登录Jupyter,放到Jupyter Notebook的配置文件中。

    执行如下命令,需要输入两次密码:(进行到Out[3]退出)

    ipython

    [root@ecs-notebook python36]# ipython
    Python 3.6.6 (default, Dec 20 2021, 09:32:25)
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.16.2 -- An enhanced Interactive Python. Type '?' for help.
    In [1]: from notebook.auth import passwd
    In [2]: passwd()
    Enter password:
    Verify password:
    Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$g14BqLddl927n/unsyPlLQ$YmoKJzbUfNG7LcxylJzm90bgbKWUIiHy6ZV+ObTzdcA

  3. 执行如下命令生成jupyter配置文件:

    jupyter notebook --generate-config

  4. 修改配置文件:

    vi ~/.jupyter/jupyter_notebook_config.py

    添加如下配置:

    # -*- coding: utf-8 -*- 
    c.NotebookApp.ip='*' #此处填写ecs对应的内网IP 
    c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$NmoAVwd8F6vFP2rX5ZbV7w$SyueJoC0a5TbCuHYzqfSx1vQcFvOTTryR+0uk2MNNZA' # 填写步骤2,Out[2]密码生成的密文
    c.NotebookApp.open_browser = False # 禁止自动打开浏览器 
    c.NotebookApp.port = 9999 # 指定端口号 
    c.NotebookApp.allow_remote_access = True