ubantu 配置远程连接jupyter lab/notebook 后台挂起

1、服务器安装JupyterLab
这里推荐直接安装Anaconda,安装好后可以通过命令jupyter lab打开测试一下。

 

2、生成配置文件

$jupyter notebook --generate-config

生成密码 此处的密码可由自己随意设定 保存好 返回的sha1字符串
$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'sha1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

4. 修改默认配置文件
$vim ~/.jupyter/jupyter_notebook_config.py'

# 将ip设置为*,意味允许任何IP访问
c.NotebookApp.ip = ‘*# 这里的密码就是上边我们生成的那一串
c.NotebookApp.password = ‘sha1:f704b702aea2:01e2bd991f9c7208ba177b46f4d10b6907810927‘ 
# 服务器上并没有浏览器可以供Jupyter打开 
c.NotebookApp.open_browser = False 
# 监听端口设置为8888或其他自己喜欢的端口 
c.NotebookApp.port = 8888
# 允许远程访问 
c.NotebookApp.allow_remote_access = True
c.NotebookApp.notebook_dir = '默认打开目录'

5.后台运行: nohup jupyter notebook --allow-root > jupyter.log 2>&1 &

 关闭:

ps -ef | grep jupyter

kill -9 ID

 

 

 

 
posted @ 2020-10-27 14:06  ZzUuOo666  阅读(196)  评论(0编辑  收藏  举报