用非默认浏览器打开jupyter时,会出现以下页面,提示需要输入token或者密码
![44d780cc4024929cc0ab91a19bc45eb7.png](https://i-blog.csdnimg.cn/blog_migrate/d4f5b958eb78698598ec276408398d23.jpeg)
以下为设置密码的方法:
1、终端输入,会生成配置文件
jupyter notebook --generate-config
成功后会显示的文件路径
![7a618f82b0267ccc3e9f341ac35c52d7.png](https://i-blog.csdnimg.cn/blog_migrate/f5703dfe4c6010087ad79580cc67e0f7.png)
2、打开改路径下的jupyter_notebook_config.py配置文件
3、打开jupyter,新建一个python文件输入
from notebook.auth import passwd
shift+enter,输入密码
获得并复制哈希密码(注意,哈希密码会变化,及时输入一样的,密码哈希密码也会不同)
4、在jupyter_notebook_config.py配置文件中找到
c.NotebookApp.password
并粘贴哈希密码
![cfde7f1d0d9c62bb0b24b591bf1de927.png](https://i-blog.csdnimg.cn/blog_migrate/7963b526d8cefa327d0a7514df7d22eb.png)
5、关闭重启jupyter即可
如果反复输入密码一直显示密码无效,则可能是jupyter_notebook_config.json文件和jupyter_notebook_config.py文件中的密码不一致,而json文件的权限更高,我们只设置了py文件导致的。
此时直接在终端强制jupyter notebook的密码,输入:
jupyter notebook password
关闭重启jupyter即可。