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生成的圖形在瀏覽器中打開
讀取本地文件。
參考資料: