Installing MySQLdb for Django on Mac OS X 10.6 Snow Leopard with MAMP

这一生的挚爱 提交于 2019-12-04 11:14:53

I was able to get this working as you'd expect.

A couple things:

First of all, the lipo: can't open input file indicates a prior compile failure. The setup scripts should really be failing and showing an earlier error; I don't know why they aren't.

Secondly, MySQLdb gets all its config information from mysql_config. So for instance, executing mysql_config --cflags gives the C compiler flags. In my case it emitted -I/usr/local/Cellar/mysql/5.5.12/include -g. In the absence of a -arch flag in there, the wrong architecture gets targeted. Also, linking architecture (in this setup file) is derived from mysql_config --cflags as well, so linking will target the wrong architecture.

Setting the architecture explicitly using ARCHFLAGS does the trick. The following script assumes that the MySQL and python builds that you are using match your machine architecture as returned by uname -m; if not, specify it explicitly.

[user]$ sudo su
[root]$ export ARCHFLAGS="-arch $(uname -m)" # or '-arch i386' or '-arch x86_64'
[root]$ pip install mysql-python
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!