python matplotlib 实战安装 初体验

相比pychart,使用matplotlib更合适。

1、网上下载matplotlib-1.1.0.win32-py2.7.exe 下载地址为     http://matplotlib.org/downloads.html
    numpy-1.8.1-win32-superpack-python2.7.exe
        
2、之前在笔记本电脑path中定义了两个python的路径,结果安装matplotlib-1.1.0.win32-py2.7.exe
numpy-1.8.1-win32-superpack-python2.7.exe 一直出错。
修改重新定义windows的环境变量path 唯一定义python,安装OK

3、import numpy as  np 成功

4、执行 import matplotlib.pyplot as plt 出错
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "G:\Python27\lib\site-packages\matplotlib\__init__.py", line 105, in <mod
ule>
    import six
ImportError: No module named six
>>>
import matplotlib

5、下载安装scipy
http://www.onlinedown.net/softdown/107395_2.htm

6、把C:\Python27\Lib\site-packages\scipy\lib中的six.py six.pyc 2个文件拷贝到C:\Python27\Lib\site-packages目录下


7、>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "G:\Python27\lib\site-packages\matplotlib\__init__.py", line 116, in <mod
ule>
    raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil

8、这个需要dateutil,http://www.lfd.uci.edu/~gohlke/pythonlibs/

使用easy_install下载安装

打开cmd,命令行,进入到Python\Scripts目录下,这个目录下执行easy_install python-dateutil,
既可以安装dateutil这个模块,
easy_install pyparsing就可以安装pyparsing这个模块


G:\Python27\Scripts>easy_install python-dateutil
Searching for python-dateutil
Best match: python-dateutil 2.2
Processing python_dateutil-2.2-py2.7.egg
Adding python-dateutil 2.2 to easy-install.pth file

Using g:\python27\lib\site-packages\python_dateutil-2.2-py2.7.egg
Processing dependencies for python-dateutil
Searching for six
Reading https://pypi.python.org/simple/six/
Download error on https://pypi.python.org/simple/six/: _ssl.c:495: The handshake
 operation timed out -- Some packages may not be found!
Couldn't find index page for 'six' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
error: The read operation timed out  

9、验证 import matplotlib
G:\Python27\Scripts>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "G:\Python27\lib\site-packages\matplotlib\__init__.py", line 140, in <mod
ule>
    raise ImportError("matplotlib requires pyparsing")
ImportError: matplotlib requires pyparsing
>>>

10、下载安装pyparsing模块 http://pan.baidu.com/s/1pJx3THp
验证 import matplotlib
 
G:\Python27\Scripts>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>

11、全部安装完成 matplotlib ok


import matplotlib.pyplot as plt 
 plt.plot([1,2,3]) 
 plt.ylabel('some numbers') 
 plt.show() 


>>> import matplotlib.pyplot as plt
>>>
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x03394610>]
>>> plt.ylabel('some numbers')
<matplotlib.text.Text object at 0x0316F950>
>>> plt.show()

测试

C:\Users\admin>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pylab import *
>>> from mpl_toolkits.mplot3d import Axes3D
>>>
>>> fig = figure()
>>> ax = Axes3D(fig)
>>> X = np.arange(-4, 4, 0.25)
>>> Y = np.arange(-4, 4, 0.25)
>>> X, Y = np.meshgrid(X, Y)
>>> R = np.sqrt(X**2 + Y**2)
>>> Z = np.sin(R)
>>>
>>> ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot')
<mpl_toolkits.mplot3d.art3d.Poly3DCollection object at 0x033E7B70>
>>>
>>> show()

 

 

 


 

你可能感兴趣的:(python matplotlib 实战安装 初体验)