000.Jupyter-notebook设置密码

1.配置文件检查

检查是否存在配置文件jupyter_notebook_config.py,这个文件的默认位置时在你的主目录下Jupyter文件夹中:

Windows: C:\Users\USERNAME\.jupyter\jupyter_notebook_config.py
OS X: /Users/USERNAME/.jupyter/jupyter_notebook_config.py
Linux: /home/USERNAME/.jupyter/jupyter_notebook_config.py

如果Jupyter文件夹不存在,或者文件夹存在然而目录内没有配置文件,运行以下命令:

$ jupyter notebook --generate-config

# 这个命令会创建Jupyter文件夹(如有必要)和配置文件jupyter_notebook_config.py。

2.设置密码

2.1 自动设置密码

$ jupyter notebook password
Enter password: ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json

2.2 手动设置密码

# 使用函数 notebook.auth.security.passwd()

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

# 将哈希密码添加到配置文件 ,即添加到jupyter_notebook_config.py中
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

posted @ 2021-06-19 16:14  可可逗豆  阅读(236)  评论(0)    收藏  举报