Jupyter notebook 远程访问

在本地使用jupyter notebook很简单,但是如果我们想在服务器上,例如Ubuntu上使用notebook就会出现无法打开网页的情况,本文介绍一下如何开启jupyter notebook的远程访问。

1. 生成配置文件

jupyter notebook --generate-config

2. 创建访问密码

首先打开ipython,利用passwd创建密码

$ ipython

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: ******
Verify password: ******
Out [2]: 'abcd:...'

复制out2中显示的密码

3. 修改jupyter notebook的配置文件

$ vim ~/.jupyter/jupyter_notebook_config.py

然后修改

c.NotebookApp.allow_remote_access = True #允许远程连接
c.NotebookApp.ip='*' # 设置所有ip皆可访问
c.NotebookApp.password = u'abcd:..' #之前复制的密码
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port =8888 #任意指定一个端口

4. 启动notebook

jupyter notebook

然后打开浏览器,地址是服务器的地址加上刚才指定的端口,完成。

posted @ 2021-06-17 16:01  MrDoghead  阅读(353)  评论(0编辑  收藏  举报