流行的在线notebook工具

背景

开发机操作系统为centos 6.5, 在需要使用python 绘图功能时,需要生成图片再把图片download 到本地机器查看,使用jupyter 配置linux server 可以直接在本地通过浏览器运行python 任务,绘图的结果也可以通过浏览器直接查看。本博客介绍如何在linux环境下配置jupyter web server

配置

首先生成jupyter 配置

jupyter notebook --generate-config

生成sha 秘钥

>>> from notebook.auth import passwd
>>> passwd()
>>> Enter password:
>>> Verify password:
>>> 'sha1:5eb7241****************8e91d9ca9d53b'

编辑jupyter 配置文件

vim ~/.jupyter/jupyter_notebook_config.py

配置ip, passwd, 以及open_browser 为False (因为我们的jupyter服务部署在服务器),
找到此三项配置后注释掉前面的#,变更为以下配置

c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.password = u'sha1:5eb7241****************8e91d9ca9d53b'
c.NotebookApp.open_browser = False

保存配置文件,启动服务

nohup jupyter notebook > jupyter.log 2>&1 &

从本地浏览器登录jupyter
pic

安装插件

安装jupyter-tabnine插件实现jupyter notebook 自动补全

pip3 install jupyter-tabnine
jupyter nbextension install --py jupyter_tabnine
jupyter nbextension enable --py jupyter_tabnine
jupyter serverextension enable --py jupyter_tabnine

结果如下:
pic