`
djangofan
  • 浏览: 35727 次
社区版块
存档分类
最新评论

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: [Error 2]

这个可以把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

解决办法:

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

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.

再然后:***************

 

总结:别折腾了,直接看我上面的那个,安装别人编译好的吧

分享到:
评论
2 楼 诗意的栖居 2012-08-21  
我按照你给的地址下载了,安装了,但是mysql却不能启动:
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (
10061)")
你知道是什么原因吗
1 楼 诗意的栖居 2012-08-21  
多谢,还是这样比较省事

相关推荐

Global site tag (gtag.js) - Google Analytics