2012-08-02 116 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

相關問題