第一步:安装ipython,安装完成后输入ipython,如下图,输入exit可退出 
​​pip install ipython 

第二步:安装jupyter  

    pip install jupyter

第三步:配置环境,通过远程方式访问jupyter notebook

       jupyter notebook --generate-config

如果出现以下提示,请在之前的命令后面加 –allow-root 
        jupyter notebook  –generate -config   –allow-root

[C 09:07:26.948 NotebookApp] Running as root is not recommended. Use –allow-root to bypass.

     生成登陆密码 这一步其实用不到,因为在虚拟机环境下不建议使用密码登录,修改配置文件的时候密码建议屏蔽,如果是云主机还是有必要 
打开ipython,创建一个密文的密码:

[root@localhost ~]# ipython

Python 3.5.2 (default, Aug 4 2017, 02:13:48)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'

第四步:修改第一步生成的配置文件,将以下几个地址修改如下,并且去掉该行前的#,使其生效 
vim   /root/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #随便指定一个端口,使用默认8888也可以

第五步:访问jupyter notebook
现在命令行下开启服务,查看系统指定的是哪个端口,有可能是8889
jupyter notebook --ip=0.0.0.0

       打开firewall浏览器,输入​http://IP:8889  这个地址是虚拟机系统的ip地址 ,如果发现无法访问,一般是centos系统防火墙没有关闭,使用以下命令进行关闭

1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running

运行:jupyter notebook  --allow-root

cmd 然后找到你要打开的文件目录 最后输入jupyter notebook --allow-root

再次访问,出现以下界面,说明可以正常访问了! 

ipython开发工具Jupyter Notebook安装_d3

输入之前设置的密码就可以登陆了。

小例子:使用jupyter notebook 练习一个99乘法表吧 

for i in range(1,10):
    for j in range(1,i+1):
        print('{} * {} = {} '.format(i,j,j*j),end='')
    print("")

jupyter 常用命令

Esc从编辑模式(edit mode)退出到命令模式(command mode)

Enter从命令模式到编辑模式

注意:编辑模式下左边是绿色的,命令模式下右边是蓝色的。

(编辑模式下)

ctrl+Enter: 运行程序/markdown代码

shift+Enter: 运行程序, 并自动跳到下一个cell

alt+Enter: 运行程序, 并自动在后面新建一个cell在

(命令模式下)

c: 复制一个cell

x: 剪切一个cell

v: 粘贴cell

a: 在当前cell上面(above)新建一个cell

b: 在当前cell下面(below)新建一个cell

m: 让当前cell变成一个markdown的cell

y: 让当前cell变成code的cell

1,2,3...: n级标题

j,k: 上下移动选中的cell, vim风格..

dd(d按两下): 删除一个cell(vim 风格...)