开发者社区 问答 正文

python 引入 MySQLdb 出错? 400 报错

python 引入 MySQLdb 出错? 400 报错 [root @localhost /]# python
Python 2.6.6 (r266:84292, Sep 11 2012, 08:28:27) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-linux-i686.egg/MySQLdb/init.py:34: DeprecationWarning: the sets module is deprecated

>>> 

该怎么解决?

展开
收起
爱吃鱼的程序员 2020-06-03 15:41:10 519 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    我是拷贝的网上的 没有试过 因为我没遇到过这个错误 也没法模拟

    错误2.
    >>> import MySQLdb
    /usr/local/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-linux-i686.egg/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
    
    解决方法
    进入./MySQL-python-1.2.2/MySQLdb目录中
    1) 在文件 "__init__" 中将:
    from sets import ImmutableSet
    class DBAPISet(ImmutableSet):
    替换为
    class DBAPISet(frozenset)
    3) 在文件 "converters.py", 把 "Set" 改为 "set"
    将return set([ i for i in s.split(',') if i ])中"Set" 改为 "set"
    将set: Set2Str,中"Set" 改为 "set"
    2) 在文件 "converters.py"中移除:
    from sets import BaseSet, Set
    修改完毕后在做编译和安装。
    

    2020-06-03 20:51:51
    赞同 展开评论