1 什么是ipython notebook?
ipython notebook是一个基于web的交互式编程环境,允许多个客户端连接到kernel。
2 如何安装和运行ipython notebook?
操作系统:Mac OS X10.10.5
安装和运行ipython notebook很简单(前提:已经安装pip):
pip install ipython
pip install jupyter
运行ipython notebook:
ipython notebook
#默认监听localhost:8888并自动打开浏览器,使用ctrl+c停止服务器并关闭所有的kernel;也可以输入jupyter notebook替代之
终端反馈信息如下:
[I 22:51:34.650 NotebookApp] Serving notebooks from local directory: /Users/xiangzhendong
[I 22:51:34.651 NotebookApp] 0 active kernels
[I 22:51:34.651 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 22:51:34.651 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
3 如何远程运行ipython?
除了在本地运行,ipython notebook还允许用户远程运行。这样做的好处在于:在客户端只需一个浏览器即可进行数据计算。
首先创建一个名为nbserver的配置文件:
ipython profile create nbserver
[ProfileCreate] Generating default config file:u'/Users/xiangzhendong/.ipython/profile_nbserver/ipython_config.py'
[ProfileCreate] Generating default config file: u'/Users/xiangzhendong/.ipython/profile_nbserver/ipython_kernel_config.py'
创建私人证书:
openssl req -x509 -nodes -days 10000 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
运行结果:

设置登录密码:
ipython
In [1]: from IPython.lib import passwd
In [3]: passwd()
Enter password:
Verify password:
Out[3]: 'sha1:f489d********************82fd5264cf'
启动public的ipython notebook:
ipython notebook —profile=nbserver
在win7的public电脑使用python notebook:
首先进入pip安装目录(并安装ipython)(前提:已经安装pip)

安装notebook:

ipython notebook --profile=nbserver
未来版本会使用jupyter notebook
4 使用
在notebook中使用`%pylab inline` or `%matplotlib inline`来生成图形,inline可以将matplotlib生成的图形在浏览器中打开

读取本地文件。

参考资料:
网友评论