zoukankan      html  css  js  c++  java
  • win64位安装python-mysqldb1.2.5

    在其他版本的mysqldb里面时间查询有问题
    最后确定还是在 1.2.5 版本下来解决,需要解决的问题就是这个:
    “Cannot open include file: 'config-win.h': No such file or directory” while installing mysql-python

    上面是在 1.2.4 版本上的,后来在 1.2.5 上面应该是解决的。但实际上,1.2.5 在Windows 64 位环境下还是有问题的,原因见后面的说明。

    安装步骤如下:
    1.安装 Microsoft Visual C++ Compiler Package for Python 2.7
    下载链接

    2.安装 MySQL Connector C 6.0.2
    下载链接

    3.下载 MySQL-python 1.2.5 源码包
    下载链接

    4.解压源码包后,修改 site.cfg 文件。
    实际上,如果你是在32 位系统上部署,那么通过pip install 安装MySQL-python 1.2.5 只需进行上面的依赖包安装即可。
    但在 64 位环境中,就会提示“Cannot open include file: 'config-win.h'” 的错误。
    原因就是 site.cfg 中写的 MySQL Connector C 为32 位版本。

    原来的 site.cfg 文件内容如下:

    引用
    # http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
    # Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
    connector = C:Program Files (x86)MySQLMySQL Connector C 6.0.2

    修改为:

    引用
    connector = C:Program FilesMySQLMySQL Connector C 6.0.2


    5.运行 python setup.py install 即可安装完成。(摘取自http://www.linuxfly.org/windows_install_mysql_python_library/)

    我在编译过程中遇到以下问题:

    1)问题: _mysql.c(34) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
    error: command ‘”C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/cl.exe”‘ failed with exit status 2

    原因:原因是安装MySQL的时候没有安装C语言库。

    解决:重新运行MySQL的安装程序,选择Modify,把“C Include Files / Lib Files”勾选上,并安装。

    2)问题:Traceback (most recent call last):
      File "setup.py", line 15, in <module>
        metadata, options = get_config()
      File "C:/MySQL-python-1.2.3/setup_windows.py", line 7, in get_config
        serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
    WindowsError: [Error 2] The system cannot find the file specified

    原因:MySQL for python 1.2.3仍然是在寻找MySQL5.0的版本

    解决:1、打开目录下site.cfg文件,修改最后一行为“registry_key = SOFTWARE/MySQL AB/MySQL Server 5.1”
    2、打开setup_windows.py文件,修改第七行为“serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE/MySQL AB/MySQL Server 5.1')”

    3)问题:build/temp.win32-2.7/Release/_mysql.pyd.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
    error: command ‘mt.exe’ failed with exit status 31

    原因:路径发生变化?

    解决:打开“你的PYTHON安装目录/Lib/distutils/msvc9compiler.py”文件,找到“ld_args.append(’/MANIFESTFILE:’ + temp_manifest)”这行代码,将其改为“ld_args.append(’/MANIFEST’)”

    (4)当编译完成以后,就可以输入setup.py install了,现在终于大功告成了!

    可以在DOS环境下输入以下命令进行测试

    C:/Users/Michael>python
    Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import MySQLdb
    >>>

  • 相关阅读:
    背包问题
    基本TCP套接字编程
    P中值选址问题的整数规划求解
    Leapms + cplex解决 混合整数规划问题
    如何用整数规划求解NP完全问题
    用Leapms建摸 / 用 CPLEX 求解 旅行商问题 整数规划问题
    用线性规划建模(确定参数)关键路径法
    流水车间调度算法分析的简单+Leapms实践--混合整数规划的启发式建模
    Wolsey "强整数规划“ 建模的+Leapms实践——无产能批量问题
    Wolsey“强整数规划模型”经典案例之一单源固定费用网络流问题
  • 原文地址:https://www.cnblogs.com/lgh344902118/p/6244266.html
Copyright © 2011-2022 走看看