配置jupyter notebook
# 查看用户目录 ~/.jupyter 路径下是否存jupyter_notebook_config.py 文件。若不存在,产生此文件。
$ jupyter notebook --generate-config
$ vim ~/.jupyter/jupyter_notebook_config.py
# 找到 c.ConnectionFileMixin.ip 并修改如下:
c.ConnectionFileMixin.ip = '0.0.0.0'
# 找到 c.NotebookApp.ip 并修改如下:
c.NotebookApp.ip = '0.0.0.0'
jupyter notebook
c.NotebookApp.ip = '*' # 允许访问此服务器的 IP,星号表示任意 IP
c.NotebookApp.password = u'sha1:xxx:xxx' # 之前生成的密码 hash 字串
c.NotebookApp.open_browser = False # 运行时不打开本机浏览器
c.NotebookApp.port = 8888 # 使用的端口
c.NotebookApp.enable_mathjax = True # 启用 MathJax
执行上述命令,会在命令行看到http://0.0.0:8888/?token=xxxxxxx的提示
打开浏览器上粘贴这个地址后,把0.0.0.0替换成服务器的IP地址即可。
网友评论