2012-08-02 7 views
10

Ich bin neu in Python und ich habe Probleme beim Aufbau von MySQLdb, um Google AppEngine SDK zum Laufen zu bringen. Ich bin gerade von Snow Leopard auf Mountain Lion Upgrade und haben die neueste XCode (4,4)Wie installiert man MySQLdb auf Mountain Lion

ich heruntergeladen habe http://sourceforge.net/projects/mysql-python/

python setup.py build 

i installiert erhalten die folgende Ausgabe in Terminal

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 

sowohl von den folgenden Verzeichnissen existieren, habe ich keine Idee, wie man das Problem löst, wenn clang nicht ausgeführt werden kann ...

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

Antwort

19

Es scheint, dass das System über clang, die in Command Line Tools von Xcode enthalten ist, nicht zu finden ist. Hast du das Tool auch installiert?

Kann über

  • öffnen Xcode
  • Preference (Command + ,)
  • Components unter der Download Registerkarte
0

installiert werden Es scheint, dass ist nicht das einzige, was Sie brauchen zu tun, überprüfe ich über den cc-Compiler, der nicht erkennt, und richtet nicht nach rechts Datei, googeln ich fand, dass ich einige Dateien ändern muss, um es vor dem Aufbau zu finden, höre nicht dort auf, jetzt, dass sein Erkennen die DYDL-Bibliotheken nicht auflädt ... es war wirklich schwer, eine echte Antwort zu finden, nur um zu arbeiten mit Python.

0

Ich fand schließlich in der ReadMe sagt, site.cfg zu bearbeiten und den Speicherort von mysql_config dort zu setzen.

1

Wenn jemand in einer schnellen und einfachen Möglichkeit für Mac OS X interessiert 10.8:

Ich nehme an, Sie XCode haben, es Kommandozeilen-Tool ist, Python und MySQL installiert.

  1. PIP Install:

    sudo easy_install pip 
    
  2. bearbeiten ~/.profile:

    nano ~/.profile 
    

    Kopieren und fügen Sie den folgenden zweizeiligen

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

    Speichern und beenden.Anschliessend den folgenden Befehl

    source ~/.profile 
    
  3. MySQLdb Installieren

    sudo pip install MySQL-python 
    

    Um zu testen, ob alles versuchen gut funktioniert nur

    python -c "import MySQLdb" 
    

Es ist wie ein Reiz für mich gearbeitet. Ich hoffe, es hilft.

+0

Dies funktionierte für mich, außer dass ich .bash_profile anstelle von .profile – mlbright

Verwandte Themen