时间:2021-07-01 10:21:17 帮助过:36人阅读
在 windows 环境安装 MySQL-python-1.2.3b1 遇到错误 ------------ C:/TDDOWNLOAD/MySQL-python-1.2.3b1.tar/MySQL-python-1.2.3b1/MySQL-python-1.2.3b1 setup.py Traceback (most recent call last): File "C:/TDDOWNLOAD/MySQL-python-1.2.3b1.tar/MySQL-
在 windows 环境安装 MySQL-python-1.2.3b1 遇到错误
------------
C:/TDDOWNLOAD/MySQL-python-1.2.3b1.tar/MySQL-python-1.2.3b1/MySQL-python-1.2.3b1
>setup.py
Traceback (most recent call last):
File "C:/TDDOWNLOAD/MySQL-python-1.2.3b1.tar/MySQL-python-1.2.3b1/MySQL-python
-1.2.3b1/setup.py", line 15, in
metadata, options = get_config()
File "C:/TDDOWNLOAD/MySQL-python-1.2.3b1.tar/MySQL-python-1.2.3b1/MySQL-python
-1.2.3b1/setup_windows.py", line 7, in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_ke
y'])
WindowsError: [Error 2]
------------
WindowsError: [Error 2]
系统找不到指定的文件。
------------
google一时没找到说明,找到的两个相关内容也是俄语的,那就看看代码好了:
file "setup_windows.py", line 7, in get_config
metadata, options = get_metadata_and_options()
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')
file "setup_common.py" line 5,8, in get_metadata_and_options
config.read(['metadata.cfg', 'site.cfg'])
options = dict(config.items('options'))
file "site.cfg" line 18 in [options]
registry_key = SOFTWARE/MySQL AB/MySQL Server 5.0
很明显,是要找到下面注册表项
HKEY_LOCAL_MACHINE/SOFTWARE/MySQL AB/MySQL Server 5.0
的 Location 键值,而这个键值取出来后就用在后面代码,用来设置 mysql
的 include 目录与 library 目录
file "setup_windows.py", line 19,21, in get_config
library_dirs = [ os.path.join(mysql_root, r'lib/opt') ]
include_dirs = [ os.path.join(mysql_root, r'include') ]
而我机器上的两个mysql一个是 XAMPP 带的,另一个是 mysql-noinstall-5.0.67-win32 都没有写
注册表相应键值。搞清楚了情况,要解决问题就很简单了
然后
setup.py build
setup.py install
测试OK
----------------
MySQL for Python
http://sourceforge.net/projects/mysql-python
MySQL for Python 1.2.3b1 release.
http://sourceforge.net/project/showfiles.php?group_id=22307&package_id=34790&release_id=658932