在Mac OSX 10.6.8上使用mysql在XAMPP中安装MySQLdb for Python时出错

时间:2012-10-09 09:32:30

标签: python macos xampp osx-snow-leopard mysql-python

我正在尝试在python中导入MySQldb并从XAMPP中的php脚本调用python脚本。这是我做的:

环境: 1. Mac OSX 10.6.8 2. Python 2.6版(默认)[64bit]

到目前为止: 1.安装XAMPP 2. MySQL配置路径:/ Applications / XAMPP / xamppfiles / bin / mysql_config 3.下载MySQL-python-1.2.4b4 4.使用MySQL的配置路径编辑site.cfg 5.执行以下命令

sudo python setup.py clean python setup.py build

出现以下错误:

running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall - Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,4,'beta',4) - D__version__=1.2.4b4 -I/Applications/XAMPP/xamppfiles/include/mysql - 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 -mmacosx-version-min=10.4 -arch i386 -arch ppc  -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:44:
/Applications/XAMPP/xamppfiles/include/mysql/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 _mysql.c:29:

/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1:警告:这是前一个定义的位置     /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as:assemblyr(/usr/bin/../libexec/gcc/darwin/ppc/as或/usr/bin/../local/libexec / gcc / darwin / ppc / as)未安装架构ppc     安装的组装商是:     架构x86_64的/usr/bin/../libexec/gcc/darwin/x86_64/as     架构i386的/usr/bin/../libexec/gcc/darwin/i386/as     在_mysql.c:44中包含的文件中:     /Applications/XAMPP/xamppfiles/include/mysql/my_config.h:1053:1:警告:“HAVE_WCSCOLL”重新定义     在/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8中包含的文件中,                  来自_mysql.c:29:/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1:警告:这是前一个定义的位置     _mysql.c:3131:致命错误:写入错误 - :管道损坏     编译终止。     lipo:无法打开输入文件:/var/tmp//ccQsr7Lk.out(没有这样的文件或目录)     错误:命令'gcc-4.2'因退出状态1而失败

1 个答案:

答案 0 :(得分:0)

yum install mysql-devel

pip install MySQL-python