黄聪:Python下安装Mysqldb出现DeprecationWarning: the sets module is deprecated from sets错误解决方案

今天下载了MySQL-python-1.2.2.win32-py2.6.rar 想试试python的数据库操作,但是安装时错误

下面是报错截图:

修改__init__.py:

*注释第34行: from sets import ImmutableSet

*在后面一行添加: ImmutableSet = frozenset

*注释第41行e: from sets import BaseSet

*在后面一行添加: BaseSet = set

##### __init__.py

#Line 35
#from sets import ImmutableSet
#class DBAPISet(ImmutableSet):
class DBAPISet(frozenset):


修改converters.py

#Line 37
#from sets import BaseSet, Set


#Line 46
#return Set([ i for i in s.split(',') if i ])
return set([ i for i in s.split(',') if i ])

#Line 132
#Set: Set2Str,
set: Set2Str,


OK,运行import mysqldb

一切正常:

原文地址:https://www.cnblogs.com/huangcong/p/2165956.html