兵马逐浪去,将象入海流。炮声震心动,惊起卧龙游。
我的博客园主页 --------- 我的知乎主页 --------- 我的github主页 --------- 我的csdn主页 --------- 我的新浪微博

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

https://zhuanlan.zhihu.com/p/25428460

 

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

Installing Jupyter Notebook

具体操作都是在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.安装科学计算包

sudo apt-get install libfreetype6-dev

sudo apt-get install gfortran

sudo apt-get install libopenblas-dev liblapack-dev

sudo apt-get apt-get install libpng12-0 libpng12-dev

 

pip install numpy

pip install matplotlib

pip install pandas

pip install scipy

pip install scikit-learn

--numpy

 

3.使用IPython

ipython --进入IPython交互环境

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

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

import datetime

datetime. --按tab键

查询功能?

 

datetime.

一些%开始的魔术命令

%magic 查看帮助

运行python脚本

%run aa.py

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

4.使用IPython notebook

jupyter notebook --启动服务

 

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

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

 

注意显示图形需要%matplotlib inline



同时open file可以打开.ipynb文件,.ipynb文件保存演示真的很好用

posted @ 2021-04-01 17:40  leoking01  阅读(193)  评论(0编辑  收藏  举报
#back-to-top { background-color: #00CD00; bottom: 0; box-shadow: 0 0 6px #00CD00; color: #444444; padding: 10px 10px; position: fixed; right: 50px; cursor: pointer; }