您的位置:首页 > 其它

Jupyter notebooks 安装与使用

2016-04-18 13:27 429 查看

Jupyter installation

Reference: http://jupyter.readthedocs.org/en/latest/install.html

如果安装了anaconda,则可以使用如下操作安装:

conda update jupyter


如果没有,则使用pip安装:

pip install jupyter


配置后台进程服务

创建用户用作运行jupyter:

addusr ipython


编辑/etc/sudoers,并将其加入sudo用户组。

ipython ALL=(ALL)   ALL


编辑/usr/lib/systemd/system/ipython-notebook.service,然后根据自己的要求进行配置,比如–ip=0.0.0.0表示允许外网访问:

[Unit]
Description=IPython notebook

[Service]
Type=simple
PIDFile=/var/run/ipython-notebook.pid
ExecStart=/usr/local/anaconda2/bin/jupyter notebook --ip=0.0.0.0 --no-browser
User=ipython
Group=ipython
WorkingDirectory=/home/ipython/notebooks

[Install]
WantedBy=multi-user.target


然后重载deamon并运行服务:

systemctl daemon-reload
systemctl enable ipython-notebook
systemctl start ipython-notebook


这样即在后台运行jupyter notebook服务了:

[root@centos7 ~]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:8787            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8888            0.0.0.0:*               LISTEN


打开防火墙

由于想使用外网接入,因此需要在iptables里面打开端口8888,否则便会connection refused:

iptables -A IN_public_allow -p tcp -m tcp --dport 8888 -m conntrack --ctstate NEW -j ACCEPT


验证安装

打开浏览器,输入ip:8888即可:



notebooks验证

然后new一个 notebook进行验证:



terminal验证

new 一个terminal 进行验证:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: