2

我已经下载了 http://sourceforge.net/projects/mysql-python/

并且还下载了 Xcode 和命令行工具。

当我使用这个命令“sudo python setup.py build”

我看到这个:

running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
running build_ext
building '_mysql' extension
clang -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 -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.7/include/python2.7 -c _mysql.c -o    build/temp.macosx-10.8-intel-2.7/_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
clang: warning: not using the clang compiler for the 'powerpc' architecture
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
         ^
1 error generated.
error: command 'clang' failed with exit status 1

我现在该怎么办???

4

2 回答 2

2

MAMP 的 MySQL 版本不附带 dev 标头。您必须下载并安装官方 MySQL 版本,或根据以下方法将标头集成到 MAMP 中:http ://dreamconception.com/tech/how-to-install-mysqldb-mysql-python-on-mamp/

于 2014-03-24T12:39:00.280 回答
2

在尝试此解决方案之前阅读此答案。无论如何,有同样的问题,这对我有用 -

brew install mysql-connector-c
brew install mysql
brew link --overwrite mysql
pip install MySQL-python
于 2018-07-19T13:04:16.690 回答