numpy

1、下载安装

源代码

http://sourceforge.net/projects/numpy/files/NumPy/

安装

python2.7 setup.py install

2、测试

导入numpy模块,出现如下错误:

[root@typhoeus79 numpy-1.8.0]# python2.7
Python 2.7.3 (default, Nov 27 2012, 17:47:24)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "numpy/__init__.py", line 143, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
>>>

原因是在源代码安装的地方进行测试,当前目录有如下文件:

[root@typhoeus79 numpy-1.8.0]# ll
drwxr-xr-x 18 501 games 4096 Nov 13 17:57 numpy

换个目录就ok了

>>> import numpy
>>> print numpy.__version__
1.9.0.dev-4d0076f

matplotlib

1、安装准备

需要安装six模块

https://pypi.python.org/simple/six/

作用:
Six is a Python 2 and 3 compatibility library. It provides utility functions
for smoothing over the differences between the Python versions with the goal of
writing Python code that is compatible on both Python versions. See the
documentation for more information on what is provided.

需要安装pyparsing

http://pyparsing.wikispaces.com/Download+and+Installation

说明:
The pyparsing module is an alternative approach to creating and executing
simple grammars, vs. the traditional lex/yacc approach, or the use of
regular expressions. The pyparsing module provides a library of classes
that client code uses to construct the grammar directly in Python code. Here is a program to parse "Hello, World!" (or any greeting of the form
"<salutation>, <addressee>!"): from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!"
hello = "Hello, World!"
print hello, "->", greet.parseString( hello ) The program outputs the following: Hello, World! -> ['Hello', ',', 'World', '!']

2、安装matplotlib

http://sourceforge.net/projects/matplotlib/?source=dlp

python2.7 setup.py install
>>> import matplotlib
>>> print matplotlib.__version__
1.3.1

http://matplotlib.org/1.3.1/api/pyplot_summary.html

3、例子

代码:

"""
This example shows how to use a path patch to draw a bunch of
rectangles for an animated histogram
"""
import numpy as np import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.path as path
import matplotlib.animation as animation fig, ax = plt.subplots() # histogram our data with numpy
data = np.random.randn(1000)
n, bins = np.histogram(data, 100) # get the corners of the rectangles for the histogram
left = np.array(bins[:-1])
right = np.array(bins[1:])
bottom = np.zeros(len(left))
top = bottom + n
nrects = len(left) # here comes the tricky part -- we have to set up the vertex and path
# codes arrays using moveto, lineto and closepoly # for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the
# CLOSEPOLY; the vert for the closepoly is ignored but we still need
# it to keep the codes aligned with the vertices
nverts = nrects*(1+3+1)
verts = np.zeros((nverts, 2))
codes = np.ones(nverts, int) * path.Path.LINETO
codes[0::5] = path.Path.MOVETO
codes[4::5] = path.Path.CLOSEPOLY
verts[0::5,0] = left
verts[0::5,1] = bottom
verts[1::5,0] = left
verts[1::5,1] = top
verts[2::5,0] = right
verts[2::5,1] = top
verts[3::5,0] = right
verts[3::5,1] = bottom barpath = path.Path(verts, codes)
patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5)
ax.add_patch(patch) ax.set_xlim(left[0], right[-1])
ax.set_ylim(bottom.min(), top.max()) def animate(i):
# simulate new data coming in
data = np.random.randn(1000)
n, bins = np.histogram(data, 100)
top = bottom + n
verts[1::5,1] = top
verts[2::5,1] = top ani = animation.FuncAnimation(fig, animate, 100, repeat=False) plt.savefig("./test.png") #测试环境属于CentOS release 5.4非界面版
#plt.show() #故show不出来

结果:

3、ipython

ipython 是一个 python 的交互式 shell,比默认的python shell 好用得多,支持变量自动补全,自动缩进,支持 bash shell 命令,内置了许多很有用的功能和函数。

https://github.com/ipython/ipython

[root@typhoeus79 20131113]# ipython
Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
Type "copyright", "credits" or "license" for more information. IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: %pycat test.
test.png test.py test.txt In [1]: %pycat test.txt
test ipython

从python版本看还是2.4.3,使用python2.7 setup.py install安装之后再次调用出现如下警告:

/usr/local/sinasrv2/lib/python2.7/site-packages/IPython/utils/path.py:424: UserWarning: Found old IPython config file u'/root/.ipython/ipy_user_conf.py' (modified by user)

将/root/.ipython移走即可。

Python之matplotlib模块安装的更多相关文章

  1. Python的第三方模块安装

    python的第三方模块安装一般使用python自带的工具pip来安装. 1.在Windows下,在安装python时勾选[安装pip]和[添加python至环境变量]. 如果在python安装目录的 ...

  2. python之 matplotlib模块之基本三图形(直线,曲线,直方图,饼图)

    matplotlib模块是python中一个强大的绘图模块 安装 pip  install matplotlib 首先我们来画一个简单的图来感受它的神奇 import numpy as np impo ...

  3. Python的MySQLdb模块安装,连接,操作,增删改

    1. 首先确认python的版本为2.3.4以上,如果不是需要升级python的版本     python -V   检查python版本 2. 安装mysql, 比如安装在/usr/local/my ...

  4. yum安装memcache,mongo扩展以及python的mysql模块安装

    //启动memcached/usr/local/memcached/bin/memcached -d -c 10240 -m 1024 -p 11211 -u root/usr/local/memca ...

  5. python之mysqldb模块安装

    之所以会写下这篇日志,是因为安装的过程有点虐心.目前这篇文章是针对windows操作系统上的mysqldb的安装.安装python的mysqldb模块,首先当然是找一些官方的网站去下载:https:/ ...

  6. Python使用matplotlib模块绘制多条折线图、散点图

    用matplotlib模块 #!usr/bin/env python #encoding:utf-8 ''' __Author__:沂水寒城 功能:折线图.散点图测试 ''' import rando ...

  7. Python中matplotlib模块解析

    用Matplotlib绘制二维图像的最简单方法是: 1.  导入模块 导入matplotlib的子模块 import matplotlib.pyplot as plt import numpy as ...

  8. Python的MySQLdb模块安装

    MySQL-python-1.2.1.tar.gz  下载地址:https://pan.baidu.com/s/1kVfH84v 然后解压,打开README(这个其实没有什么鸟用) 里面有安装过程: ...

  9. python之路-模块安装 paramiko

    paramiko介绍(全是洋文,看不懂啊,赶紧有道翻译吧,等有朝一日,我去报个华尔街): "Paramiko" is a combination of the esperanto ...

随机推荐

  1. Java web JavaScript DOM 编程

     JavaScript DOM 编程 (1).DOM概述及分类 (2).DOM结构模型:XML DOM 和 HTML DOM 关系? (3).结点,结点树,结点属性与方法? 1.DOM是什么? d ...

  2. Scala基础之注解(annotation

    在学习Scala的过程中,总会碰到一些注解: // Predef.scala @inline def implicitly[T](implicit e: T) = e @deprecated(&quo ...

  3. aspnet中通过多条件筛选来显示数据的实现

    UI图: 功能实现: 1.勾选住哪个选项之后,就加入了筛选.支持姓名的模糊查询. 2.对筛选出来的数据可以直接修改,并更新回数据库. 说明:显示的数据来自T_User表.数据显示控件使用的是 List ...

  4. 张高兴的 Windows 10 IoT 开发笔记:ADXL345 加速度传感器

    GitHub : https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/ADXL345Demo

  5. hdu 4117 -- GRE Words (AC自动机+线段树)

    题目链接 problem Recently George is preparing for the Graduate Record Examinations (GRE for short). Obvi ...

  6. Memcached统计命令

    1. Memcached stats命令: Memcached stats 命令用于返回统计信息例如 PID(进程号).版本号.连接数等. 语法: stats 输出信息说明: pid: memcach ...

  7. 一个让你想到即可做到的web弹窗/层----Layer

    Layer     layer是一款近年来备受青睐的web弹层组件,她具备全方位的解决方案,致力于服务各水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验. 在与同类组件的比较中,layer总是 ...

  8. JF厂V8版本爱彼AP15703,黄家橡树离岸型,超越N厂神器

    根据调查的结果JF厂的爱彼AP15703几乎常年垄断了爱彼的市场,销量持续性的排在爱彼整个品牌中的第一位.JF厂这两年一直在攻克爱彼整个品牌,有了解的都知道 爱彼15703以前是N厂的五大复刻神器的代 ...

  9. js原生API妙用(一)

    复制数组 我们都知道数组是引用类型数据.这里使用slice复制一个数组,原数组不受影响. let list1 = [1, 2, 3, 4]; let newList = list1.slice(); ...

  10. svn 常用命令行

    1.将文件checkout到本地目录    svn checkout path(path是服务器上的目录)    例如:svn checkout svn://192.168.1.1/pro/domai ...