在Mac OS 10.6 Snow Leopard上安装MySQL_python 1.2.2时的GCC错误

0 投票
2 回答
3343 浏览
提问于 2025-04-16 13:12

我正在尝试在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

有没有人见过这个错误?

2 个回答

0

根据错误提示,某些东西被重新定义了。过去我解决这个问题的方法是把出问题的声明在库的源代码中注释掉。不过,这个办法显然有一些明显的问题……

3

我快速在谷歌上搜索了一下,找到了这个答案

为了让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

撰写回答