2012-08-02 117 views
10

我是Python新手,在构建MySQLdb时遇到问题,试图让Google AppEngine SDK运行。我刚刚从雪豹升级到山狮,并且已经安装了最新的XCode(4.4)如何在Mountain Lion上安装MySQLdb

我已经下载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 

以下两个输出以下目录存在,我不知道如何解决铛不能执行的问题...

/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 
/usr/local/mysql/include 

回答

19

看起来系统抱怨找不到clang,它包含在XcodeCommand Line Tools中。你是否也安装了该工具?

可以通过

  • 打开Xcode
  • 偏好(Command + ,
  • ComponentsDownload标签
0

下安装看来,这不就是你唯一需要的东西要做的是,我检查一下没有识别的cc编译器,并且没有指向正确的方向文件,谷歌搜索,我发现我需要改变一些文件才能在创建之前找到它,并不会停留在那里,现在它的识别不会对DYDL库进行收费......开始工作真的很难找到真正的答案与蟒蛇。

0

我终于发现它在自述文件中说要编辑site.cfg并将mysql_config的位置放在那里。

1

如果有人有兴趣的Mac OS X 10.8快速简便的方法:

我假设你拥有的XCode,它的命令行工具,Python和MySQL的安装。

  1. 安装PIP:

    sudo easy_install pip 
    
  2. 编辑〜/ .profile文件:

    nano ~/.profile 
    

    复制并粘贴以下两个行

    export PATH=/usr/local/mysql/bin:$PATH 
    export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/ 
    

    保存并退出。后记执行以下命令

    source ~/.profile 
    
  3. 安装MySQLdb的

    sudo pip install MySQL-python 
    

    为了测试,如果一切工作正常,只是尝试

    python -c "import MySQLdb" 
    

它的工作对我来说就像魅力。我希望它有帮助。

+0

这工作对我来说除了我用.bash_profile而不是.profile – mlbright 2013-09-17 18:31:47

相关问题