hujh20 发表于 2017-4-27 10:39:12

MySQLdb for python 安装

  升级到了python2.7.1,没有吸取以前的教训,再一次的跌倒在这个上面,浪费了半个小时;
  标准解决方案:
  http://www.codegood.com/downloads去这里下载老外编译好的版本,直接安装,别费劲了;
  如果有试图编译安装的,你可以会先遇到:
  D:/MySQL-python-1.2.3/setup_windows.py", line 7, in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_ke
y'])WindowsError:
  这个可以把setup_windows.py修改成下面的样子(直接指明mysql_root):
  #serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
#mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')
mysql_root = r'D:/wamp/bin/mysql/mysql5.5.8'
  接下来还可能遇到:
  building '_mysql' extension
error: Unable to find vcvarsall.bat
  解决办法:
  

[*]首先安装MinGW,在MinGW的安装目录下找到bin的文件夹,找到mingw32-make.exe,复制一份更名为make.exe;
[*]把MinGW的路径添加到环境变量path中,比如我把MinGW安装到D:/MinGW/中,就把D:/MinGW/bin添加到path中;
[*]打开命令行窗口,在命令行窗口中进入到要安装代码的目录下;
[*]输入如下命令就可以安装了。
    python setup.py install build --compiler=mingw32

  
  然后是第三个错误:
  
  gcc: /Zl: No such file or directory
_mysql.c:34:24: fatal error: config-win.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

This error is caused by /Zl parameter, as they are special parameters used only by VC. We could delete them on setup_window.py.
  再然后:***************
  总结:别折腾了,直接看我上面的那个,安装别人编译好的吧
页: [1]
查看完整版本: MySQLdb for python 安装