Jupyter 远程服务器部署与使用

部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pip3 install jupyter -i https://pypi.douban.com/simple/

# 登陆服务器生成配置文件
jupyter notebook --generate-config

Writing default config to: /root/.jupyter/jupyter_notebook_config.py
# 生成密码
ipython3
from notebook.auth import passwd
passwd()
Enter password:
Verify password:
Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$d7KY0z59c4W2D35oUhsfOQ$ksuiDsWhogYFfuNqUxSa5IpayeOQVecbROGoXceza/k'
# 修改配置文件

# 将ip设置为*,意味允许任何IP访问
c.NotebookApp.ip = '*'
# 这里的密码就是上边我们生成的那一串
c.NotebookApp.password = 'sha1:3c7ece6d01a3:aef0f9818ea49be2c2f2cc5f5a6228fd327ec00d'
# 服务器上并没有浏览器可以供Jupyter打开
c.NotebookApp.open_browser = False
# 监听端口设置为8888或其他自己喜欢的端口
c.NotebookApp.port = 8888
# 我们可以修改jupyter的工作目录,也可以保持原样不变,如果修改的话,要保证这一目录已存在
#c.MappingKernelManager.root_dir = '/root/jupyter_run'
# 允许远程访问
c.NotebookApp.allow_remote_access = True

jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

nohup jupyter notebook --ip=0.0.0.0 --no-browser --allow-root &