zoukankan      html  css  js  c++  java
  • matplotlib 和 pandas 两个包的安装

    matplotlib是强大的python 绘图包。pandas 是强大的python分析工具包。numpy是强大的python统计包。

    都超级好用,而且最近开始动手实践机器学习算法了。特此备注一下安装过程:

    -----------------------------------------

    1. matplotlib 

    安装起来有点费劲,果然python或者pc或者包的版本和依赖不一样,容易出现各种bug。

    windows环境下:

    1)python 2.7 的64位下载安装

    2)安装 64位的 matplotlib,pyparsing,dateutil,scipy, numpy

    下载四个包: http://download.csdn.net/detail/am45337908/9218431  

    可能总是提示“ Python Version 2.7 required which was not found in the registry.0”

    其实是注册表的原因,无法识别。

    解决方法: 参考 http://www.cnblogs.com/thinksasa/archive/2013/08/26/3283695.html

    新建一个register.py 文件,把一下代码贴进去,保存

    复制代码
    #
    # script to register Python 2.0 or later for use with win32all
    # and other 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/distutils-sig@python.org/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) 安装完后输入 import matplotlib 验证是否成功。

    遇到问题:

    python ImportError: DLL load failed: %1 不是有效的 Win32 应用程序

    在IDE上,看到python的版本是32位的。而我的windows是64位,其他一些安装包都是64位的,所以重新下载64位的python就是了。

    4)python错误:No module named six

    将site-packages/scipy/lib 目录下的三个文件
    six.py
    six.pyo
    six.pyc
    复制到site-packages目录下就可以了。
     

    mac环境下:

    下载numpy,scipy,matplotlib的dmg文件。 
     

    2. pandas

    1) 配置python的环境变量,下载解压pip;

    2) 从 https://bootstrap.pypa.io/ez_setup.py 下载ez_setup.py  

        然后在cmd下执行它,可以自动安装setuptools包; 

    3) 去pip的解压目录下,执行  python setup.py install;

         完成pip安装后,配置 pip环境变量

    4) 最后在cmd 执行:

            pip install  D:...pandas_file.whl

    3. 说明

    matlibplot是exe 文件, pandas是whl文件。

    个人感觉exe文件安装很方便,下载打开一步到底即可。whl文件可能是因为exe资源不多,才考虑安装的,需要借助于pip。

    不过,配置了python和pip的环境变量之后,cmd命令下能做的事情更多了,也不错。

    4. whl文件安装

    今天才发现,whl文件原来安装如此简单!!!

    http://www.lfd.uci.edu/~gohlke/pythonlibs/,在这里能下载到很多我们要用的模块。

    比如。找到pandas 的.whl格式。

    将.whl改成.zip然后就可以解压了,解压得到两个文件夹,把这两个文件夹拷贝到你Python的目录下。就okay 啦!

  • 相关阅读:
    第五周作业
    第四周编程总结
    第六周作业
    2019春第五周作业
    2019年春季学期第四周作业
    2019年春季学期第三周作业
    求最大值及其下标
    7-1
    第十周课程总结
    第九周课程总结&实验报告(七)
  • 原文地址:https://www.cnblogs.com/skyEva/p/5750870.html
Copyright © 2011-2022 走看看