本文记录如在服务器中配置运行jupyter notebook。配置完成后可以远程访问juypyter notebook。
1 生成配置文件
jupyter notebook --generate-config
输出
Writing default config to: /home/ubuntu/.jupyter/jupyter_notebook_config.py
2 修改配置文件
编辑生成的jupyter_notebook_config.py
文件
nano /home/ubuntu/.jupyter/jupyter_notebook_config.py
在开头处加入如下代码:
代码如下(方便粘贴):
# 设置可以访问的ip, 默认是localhost, 将其改为 '*'
c.NotebookApp.ip = '*'
# 笔记本的默认打开目录
c.NotebookApp.notebook_dir = '/home/ubuntu/jupyter-notebook'
# 笔记本启动后是否打开浏览器, 设为 False
c.NotebookApp.open_browser = False
# 默认访问端口
c.NotebookApp.port = 8888
运行jupyter notebook
命令:
此时在浏览器中输入<服务器ip>:<端口号>
,出现下面效果:
然后再把命令行中的token
值粘贴,并设置密码即可。成功登录: