如何在windows下安装matplotlib

1. 安装python-2.7.9.amd64版本,好像只有2.7.9版本才支持pip

2.      注册python到注册表

#
# script to register Python 2.0 or later for use with
# Python extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/[email protected]/msg10512.html

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
    installpath, installpath, installpath
)

def RegisterPy():
    try:
        reg = OpenKey(HKEY_CURRENT_USER, regpath)
    except EnvironmentError as e:
        try:
            reg = CreateKey(HKEY_CURRENT_USER, regpath)
            SetValue(reg, installkey, REG_SZ, installpath)
            SetValue(reg, pythonkey, REG_SZ, pythonpath)
            CloseKey(reg)
        except:
            print "*** Unable to register!"
            return
        print "--- Python", version, "is now registered!"
        return
    if (QueryValue(reg, installkey) == installpath and
        QueryValue(reg, pythonkey) == pythonpath):
        CloseKey(reg)
        print "=== Python", version, "is already registered!"
        return
    CloseKey(reg)
    print "*** Unable to register!"
    print "*** You probably have another Python installation!"

if __name__ == "__main__":
    RegisterPy()


3.   安装 numpy-1.7.0-win32-superpack-python2.7.exe

4. 下载numpy-1.9.2+mkl-cp27-none-win_amd64.whl文件,通过   pip install numpy-1.9.2+mkl-cp27-none-win_amd64.whl

5. 安装python_dateutil-2.4.2-py2.py3-none-any.whl  , 下载文件,然后到相应的目录pip install  python_dateutil-2.4.2-py2.py3-none-any.whl

6. 安装 pyparsing-2.0.3-py2-none-any.whl  下载文件,然后到相应的目录pip install  pyparsing-2.0.3-py2-none-any.whl 

7. 安装scipy  ,直接通过安装文件安装。 scipy_0.14.0.win_amd64_py2.7.exe

   在这里下载http://download.csdn.net/detail/z1102252970/8194609        win64 python2.7+numpy+scipy找了好久才整理出来的

8、输入以下代码不报错:
import matplotlib
import numpy
import scipy
import pyparsing
import matplotlib.pyplot as plt

9、验证一个简单的例子
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.ylabel('some numbers')
plt.show()

======================================


也可以直接安装Anaconda,以上所有步骤都省了,一步到位。

http://www.gimoo.net/t/1405/541f9dd1d0a5d.html


你可能感兴趣的:(python,numpy,matplotlib,Anaconda)