Skip to main content
 首页 » 编程设计

python之MYSqlDb 和 Python 一起玩得很好

2025年05月04日26lexus

免责声明:我尝试了很多搜索和程序来使它正常工作,正如我在尝试用谷歌搜索这个问题时发现的那样,但似乎都没有效果。

当我尝试在 Python Interactive Shell 下导入 MySQLdb 时,我得到以下信息...

 Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)  
    [GCC 4.2.1 (Apple Inc. build 5664)] on darwin 
    Type "help", "copyright", "credits" or "license" for more information. 
    >>> import MySQLdb 
    Traceback (most recent call last): 
      File "<stdin>", line 1, in <module> 
      File "MySQLdb/__init__.py", line 23, in <module> 
        (version_info, _mysql.version_info)) 
    ImportError: this is MySQLdb version (1, 2, 4, 'beta', 4), but _mysql is version (1, 2, 4, 'final', 1) 

有什么建议吗?我通过 pip

安装了 MySQLdb

请您参考如下方法:

我没有 Mac,所以我无法真正测试这个,但是,Mac 似乎对这个模块有问题。你看过这个人的网站吗?在 Mac 上完成设置似乎非常彻底。

http://learninglamp.wordpress.com/2010/02/21/mysqldb-python-mysql-and-os-x-a-match-made-in-satans-bum/

希望这对您有所帮助。