Jupyter Notebook 配置学习笔记

Jupyter Notebook 配置学习笔记

一、生成配置文件

  1. 生成默认配置文件

    bash 复制代码
    jupyter notebook --generate-config
    • 这会在 ~/.jupyter/ 目录下生成一个默认的配置文件 jupyter_notebook_config.py

    • 示例输出:

      复制代码
      Writing default config to: /public/home/2022099/.jupyter/jupyter_notebook_config.py

二、设置密码

  1. 设置密码

    bash 复制代码
    jupyter notebook password
    • 输入密码并验证后,密码的哈希值会被写入到 ~/.jupyter/jupyter_server_config.json 文件中。

    • 示例输出:

      复制代码
      [JupyterPasswordApp] Wrote hashed password to /public/home/2022099/.jupyter/jupyter_server_config.json
  2. 查看 jupyter_server_config.json 文件内容

    json 复制代码
    {
      "IdentityProvider": {
        "hashed_password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$K1xFxKj6Tuqu9osrt7uNVw$NmnIHtXd7KroOQ3t1d6sX5doYiymcgBaCBTjUi4ioEM"
      }
    }

三、编辑 jupyter_notebook_config.py 文件

  1. 打开配置文件

    bash 复制代码
    vim ~/.jupyter/jupyter_notebook_config.py
  2. 添加或修改以下配置

    python 复制代码
    # 启用密码保护
    c.ServerApp.password_required = True
    c.ServerApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$K1xFxKj6Tuqu9osrt7uNVw$NmnIHtXd7KroOQ3t1d6sX5doYiymcgBaCBTjUi4ioEM'
    
    # 禁止自动打开浏览器
    c.ServerApp.open_browser = False
    
    # 允许从任何 IP 地址访问
    c.ServerApp.ip = '0.0.0.0'
    
    # 设置端口
    c.ServerApp.port = 8888
    
    # 允许 root 用户登录
    c.ServerApp.allow_root = True
    
    # 设置启动根目录(如果需要指定特定目录,取消注释并填写路径)
    # c.ServerApp.root_dir = '/path/to/your/directory'
    
    # 允许访问隐藏文件
    c.ContentsManager.allow_hidden = True

四、启动 Jupyter Notebook

  1. 启动 Jupyter Notebook

    bash 复制代码
    jupyter notebook
    • 根据配置文件中的设置,Jupyter Notebook 会启动在指定的 IP 地址和端口上。

五、其他注意事项

  1. 确保配置文件路径正确

    • 配置文件路径为 ~/.jupyter/jupyter_notebook_config.py~/.jupyter/jupyter_server_config.json
    • 如果路径不正确,可能导致配置不生效。
  2. 备份配置文件

    • 在修改配置文件之前,建议备份原始文件,以防出现问题。
  3. 检查权限

    • 确保你对配置文件和启动目录有适当的读写权限。
相关推荐
萘柰奈12 分钟前
Unity学习--2D动画--[序列帧动画]2D序列帧动画
学习·unity·游戏引擎
EQ-雪梨蛋花汤13 分钟前
【Unity笔记】Unity 模型渲染优化:从 Batching 到 GI 设置的完整指南
笔记·unity·游戏引擎
电饭叔20 分钟前
如何代码化,两点之间的距离
笔记·python·算法
TL滕23 分钟前
从0开始学算法——第十三天(Rabin-Karp 算法练习)
笔记·学习·算法·哈希算法
呱呱巨基36 分钟前
C++ 红黑树
数据结构·c++·笔记·学习
TL滕37 分钟前
从0开始学算法——第十三天(Rabin-Karp 算法)
笔记·学习·算法
RisunJan1 小时前
【行测】类比推理-古称今称全同
学习
Math_teacher_fan1 小时前
第三篇:三角形问题详解
人工智能·学习·机器学习·几何学
玦尘、1 小时前
《统计学习方法》第7章——支持向量机SVM(上)【学习笔记】
学习·支持向量机·学习方法
EveryPossible1 小时前
地图学习练习
大数据·学习