我是Python的新手,我在构建MySQLdb时遇到了麻烦,试图让Google AppEngine SDK运行。我刚从Snow Leopard升级到Mountain Lion并安装了最新的XCode(4.4)
我已下载http://sourceforge.net/projects/mysql-python/
python setup.py build
我在终端
中获得以下输出running build
running build_py
creating build
creating build/lib.macosx-10.8-intel-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.8-intel-2.7
creating build/lib.macosx-10.8-intel-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
creating build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.8-intel- 2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.8-intel-2.7
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,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -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 -Os -g -fno-common -fno-strict-aliasing -arch x86_64
unable to execute clang: No such file or directory
error: command 'clang' failed with exit status 1
以下两个目录都存在,我不知道如何解决clang无法执行的问题......
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
/usr/local/mysql/include
答案 0 :(得分:19)
系统似乎抱怨无法找到clang
Command Line Tools
中包含的Xcode
。你也安装了这个工具吗?
可以通过
安装Xcode
Command
+ ,
)Components
位于Download
标签下
答案 1 :(得分:1)
如果有人对Mac OS X 10.8的快速简便方法感兴趣:
我假设你有XCode,它是命令行工具,安装了Python和MySQL。
安装PIP:
sudo easy_install pip
编辑〜/ .profile:
nano ~/.profile
复制并粘贴以下两行
export PATH=/usr/local/mysql/bin:$PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
保存并退出。后记执行以下命令
source ~/.profile
安装MySQLdb
sudo pip install MySQL-python
要测试一切是否正常,请尝试
python -c "import MySQLdb"
它对我来说就像一个魅力。我希望它有所帮助。
答案 2 :(得分:0)
似乎这不是你需要做的唯一的事情,我检查一下无法识别的cc编译器,并且没有指向正确的文件,谷歌搜索我发现我需要更改一些文件才能找到它在构建之前,并不止于此,现在它的识别并没有给DYDL库收费......为了开始使用python,真的很难找到真正的答案。
答案 3 :(得分:0)
我终于发现它在自述文件中说编辑site.cfg并将mysql_config的位置放在那里。