10

I'm new to Python and I'm having trouble building MySQLdb, in an attempt to get Google AppEngine SDK running. I have just upgraded from Snow Leopard to Mountain Lion and have installed the latest XCode (4.4)

I've downloaded http://sourceforge.net/projects/mysql-python/

python setup.py build 

i get the following output 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

both of the following directories exist, i have no idea how to resolve the issue with clang not being able to execute...

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

4 回答 4

19

It seems that the system is complaining about not be able to find clang, which is included in Command Line Tools of Xcode. Did you installed the tool as well?

Can be installed via

  • Open Xcode
  • Preference (Command + ,)
  • Components under the Download tab
于 2012-08-03T02:11:16.953 回答
1

If someone is interested in a quick and easy way for Mac OS X 10.8:

I assume you have XCode, it's command line tool, Python and MySQL installed.

  1. Install PIP:

    sudo easy_install pip
    
  2. Edit ~/.profile:

    nano ~/.profile
    

    Copy and paste the following two line

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

    Save and exit. Afterwords execute the following command

    source  ~/.profile
    
  3. Install MySQLdb

    sudo pip install MySQL-python
    

    To test if everything works fine just try

    python -c "import MySQLdb"
    

It worked like a charm for me. I hope it helps.

于 2013-08-12T01:55:46.670 回答
0

It seems that is not the only thing that you need to do, i check about the cc compiler that is not recognizing, and is not directing to the right file, googling i found that i need to change some files to found it before building, does not stop there, now that its recognizing is not charging the DYDL Libraries... it has been really hard to find a real answer just to start working with python.

于 2012-08-10T17:09:56.930 回答
0

I finally found it says in the ReadMe to edit site.cfg and put the location of mysql_config in there.

于 2012-08-25T10:34:11.380 回答