在Windows 7上安装Python MySQLdb时出错
请看下面的错误追踪信息,这是不是权限问题呢?
C:\Project\MySQL-python-1.2.3>python setup.py
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "C:\Project\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
C:\Project\MySQL-python-1.2.3>
使用的Python版本是 (ActiveState) 2.7.1
3 个回答
0
在mysql-python的构建目录中的site.cfg文件里,找到下面这一行,并把它修改成指向你MySQL的安装位置。
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
1
我这边也遇到了同样的问题,安装的Python和MySQL版本都是一样的(都是XAMPP的一部分)。可以推测,前提条件是指“原版”的MySQL安装,而不是包含在*AMP包里的那种。
这虽然不是解决从tarball安装问题的答案,但有适用于ActiveState Python 2.7.1和Windows 7的MySQLdb二进制包可以在这个网站找到:
http://servut.us/akx/2010/09/mysqldb-windows-binaries-python-26-27/
3
根据MySQLDb的说明,使用这个工具之前,你需要先安装MySQL。