1. 安装Jupyter服务
pip3 install jupyter
2. 远程访问配置
2.1 生成密码
进入python3交互模式:
python3
运行以下代码:
from jupyter_server.auth import passwd
passwd()
运行截图:
保存这串以argon2
开头的字符串,按下ctrl+D
退出python3交互模式。
2.2 生成配置文件
jupyter notebook --generate-config
该命令会生成文件~/.jupyter/jupyter_notebook_config.py
2.3 修改配置文件
使用vim修改~/.jupyter/jupyter_notebook_config.py
文件,同样也可以用其他编辑软件进行修改。
2.3.1 导入模块
在~/.jupyter/jupyter_notebook_config.py
的第一行插入以下语句:
from jupyter_server.auth import PasswordIdentityProvider
2.3.2 设置密码
由于之前的配置方式已经过时,我们使用PasswordIdentityProvider
来设置密码。在~/.jupyter/jupyter_notebook_config.py
中插入这样一条语句:
PasswordIdentityProvider.hashed_password = u"argon2:*************"
这里的字符串就是刚才使用passwd()
生成的字符串。
2.3.3 修改其他配置
找到这些被注释掉的语句,然后修改为以下内容:
c.ServerApp.ip = '*'
c.ServerApp.open_browser = False
c.ServerApp.port = 8888
c.ServerApp.allow_remote_access = True
3 启动服务
jupyter notebook