【问题标题】:GCC error when installing MySQL_python 1.2.2 (Mac OS 10.6 Snow Leopard)安装 MySQL_python 1.2.2 (Mac OS 10.6 Snow Leopard) 时出现 GCC 错误
【发布时间】:2011-07-10 18:17:07
【问题描述】:

我正在尝试在 Snow Leopard 上安装 MySQL_python 1.2.2(我特别需要这个版本,而不是当前的 1.2.3),并在下面出现此错误。

安装命令:

pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download

还有一部分痕迹:

copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants

running build_ext

building '_mysql' extension

creating build/temp.macosx-10.6-universal-2.6

/usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,2,'final',0) - D__version__=1.2.2 -I/usr/local/mysql/include - I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o    build/temp.macosx-10.6-universal-2.6/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL

In file included from _mysql.c:35:

/usr/local/mysql/include/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined

In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,

             from pymemcompat.h:10,

             from _mysql.c:29:

/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1: warning: this is the location of the previous definition

In file included from /usr/local/mysql/include/mysql.h:47,

             from _mysql.c:40:

/usr/include/sys/types.h:92: error: duplicate ‘unsigned’

/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers

error: command '/usr/bin/gcc-4.2' failed with exit status 1

以前有人见过这个错误吗?

【问题讨论】:

    标签: python mysql gcc mysql-python


    【解决方案1】:

    快速谷歌搜索产生this answer

    为了让 mysqldb 在 leopard 上工作,我发现我必须编辑 _mysql.c 并删除以下行:

    #ifndef uint
    #define uint unsigned int
    #endif     
    

    我还必须编辑 site.cfg 并将 threadsafe 标记为 False。

    完成此操作后,我设法安装了 MySQLdb,太棒了!不是这样 很快,还有一个问题:

    引用自:.../_mysql.so 原因:找不到图片

    解决办法:

    sudo ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib/mysql
    

    【讨论】:

    • 对于以后的搜索者,我只需要从这个链接迈出第一步(在_mysql.so中注释掉三行)。
    • 其实没必要这么做。只需安装 python-dev 和 libmysqlclient,然后 pip install MySQL-python。
    • @shakabra:你没看问题的第一句话吧?
    【解决方案2】:

    正如错误所说,事情已被重新定义。过去,我通过在正在构建的库的源代码中注释掉有问题的声明来解决这个问题。然而,该解决方案存在一些明显的问题......

    【讨论】:

      猜你喜欢
      • 2011-01-25
      • 2010-11-30
      • 1970-01-01
      • 2013-07-15
      • 2013-01-16
      • 2011-09-08
      • 2010-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多