由于anaconda安装时已经有了jupyter notebook所以只需要配置好就可以!
一、添加root启动权限
如果输入 jupyter notebook --generate-config提示: Running as root is not recommended. Use –allow-root to bypass. 则在后边加上 --allow-root jupyter notebook --generate-config --allow-root
二、修改配置文件
vim /root/.jupyter/jupyter_notebook_config.py 将c.NotebookApp.allow_root = False前边的 '#'去掉,在把False修改为True
三、生成登录密码
因为采用的服务器环境所有建议生成一个密码
打开 ipython from notebook.auth import passwd passwd() Enter password: 输入一次密码 Verify password: 再次输入密码 'sha1:ae9e423f48ae:a8................................'
四、再次修改配置文件
vi /root/.jupyter/jupyter_notebook_config.py c.NotebookApp.ip='服务器IP' c.NotebookApp.password = u'sha1:ae9e423f48ae:a8................' c.NotebookApp.open_browser = False c.NotebookApp.port =7777 #任意空闲端口,使用默认7777也可以,有些机器默认会占用8888端口,建议改为其他端口
五、启动
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root 如果打开输入地址无法访问则需要关闭一下防火墙 systemctl stop firewalld.service #关闭firewall systemctl disable firewalld.service #禁止firewall开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running) 在安全组规则里开放你的开放端口比如这里的7777 建议安装一下宝塔面板,更加方便的进行服务器的监测和管理,包括端口开放等等。
最后再次启动命令行出现:
浏览器 输入出现这样就成功了
在关闭ssh界面后也能够使用notebook,使用如下代码:
nohup jupyter notebook –ip=0.0.0.0 –no-browser (–allow-root)& #nohup为后台挂起功能
微信扫描下方的二维码阅读本文