python安装MySQLdb的问题 ImportError: DLL load failed

在windows下面默认安装的python2.6再安装MySQLdb会遇到不少神奇的问题,如缺乏库,编译错误等 python

例如python2.5出现 mysql

import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\Lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
    import _mysql
ImportError: DLL load failed: 找不到指定的程序。 sql

解决方案: windows

把mysql安装目录的bin\libmySQL.dll文件复制到python安装目录的Lib\site-packages下 ide

python2.6出现 ui

Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\Lib\site-packages\MySQLdb\__init__.py", line 19, in <module>     import _mysql
ImportError: DLL load failed: 找不到指定的模块。 spa

下载libmmd.dll和libguide40.dll两个dll文件并复制到python安装目录的Lib\site- packages下 .net

两个dll文件Google一下便可找到 code

还有一个 orm

Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
D:\usr\local\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet

解决方案:

1) 在文件 "__init__" 中将:

from sets import ImmutableSet 
class DBAPISet(ImmutableSet): 

替换为

class DBAPISet(frozenset)

2) 在文件 "converters.py"中移除:

from sets import BaseSet, Set

3) 在文件 "converters.py", 把 "Set" 改成 "set" (重要提示: 只有2个地方要改):

line 48: return set([ i for i in s.split(',') if i ])
line 128: set: Set2Str,

参见:

http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/2316047?message=5808948

最后再介绍一个无敌方法:

国外有个大牛直接帮咱们编译好了不会出问题的MySQLdb, 去下面的网址下载安装就能解决了
http://www.codegood.com/archives/4

相关文章
相关标签/搜索