您的位置:首页 > 编程语言 > Python开发

Ubuntu--IPython和IPython Notebook的安装和简单应用

2018-01-03 22:43 441 查看
IPython是一个python shell的扩展,强调了IPython可交互性和探索性计算 。

官网(http://IPython.org/)上的介绍如下

The goal of IPython is to create a comprehensive environment for interactive and exploratory computing. To support this goal, IPython has three main components:

    An enhanced interactive Python shell.

    A decoupled two-process communication model, which allows for multiple clients to connect to a computation kernel, most notably the web-based notebook

    An architecture for interactive parallel computing.

 

里面3个组件:

IPython shell、IPython Notebook、交互是并行计算的架构

其中IPython Notebook目前已经成为用Python做教学、计算、科研的一个重要工具,很多示例都是用.ipynb文件。

这次主要介绍在Python已经安装的前提下,IPython和IPython Notebook的安装和简单使用。

当然也可以直接安装 Anaconda等这些发型包,不用自己一个个安装了。

安装参考文档

--IPython

http://IPython.org/install.html

--IPython Notebook

http://jupyter.readthedocs.org/en/latest/install.html#new-to-python-and-jupyter

具体操作都是在pyenv 351环境下使用,注意进入和退出环境的比例:

pyenv activate env351

pyenv deactivate


0.系统准备工作

系统默认没有装g++,如果需要使用IPython Notebook,那就装

sudo apt-get install g++


1.安装IPython及IPython Notebook

pip install IPython

pip install urllib3 --安装IPython Notebook的依赖

pip install jupyter --安装IPython Notebook


2.使用IPython

ipython  --进入IPython交互环境

提示符不一样,看一下示例



如果不知道具体函数可以使用tab键提示

import datetime

datetime. --按tab键

查询功能?

datetime.



一些%开始的魔术命令

%magic 查看帮助

运行python脚本

%run aa.py

%run -i aa.py --继承变量


3.使用IPython notebook

jupyter notebook

在浏览器里面可以看到IPython notebook的交互环境



每个cell可以放一组命令, 按shift + enter可以执行



同时open file可以打开.ipynb文件,.ipynb文件保存演示真的很好用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Ubuntu