您的位置:首页 > 编程语言 > Python开发

在Mac osx v10.9上安装mysql-python

2014-04-15 20:54 260 查看
想在新买的Mac机上安装mysql-python驱动,遇到了一大堆的麻烦,最后终于通过万能的谷歌找到最终解决方案。

现象:sudo pip install mysql-python 遇到各种问题

building '_mysql' extension

creating build/temp.macosx-10.9-intel-2.6

cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32
-DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/Applications/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.9-intel-2.6/_mysql.o
-Os -g -fno-strict-aliasing -arch x86_64

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

原因出在最新的Xcode5.1,编译工具太新了。

所以在pip时要添加一条信息:ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install mysql-python

最后成功安装。

这对于PostgreSQL驱动的安装或许也有效。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  解决方案 django