2014-09-11 2 views
12

Non riesco a installare Python-MySQL, ho già provato con easy_install, pip e fonti .. E ottengo sempre lo stesso errore. Questo è ciò che ottengo:Impossibile installare Python-MySQL su OS X 10.10 Yosemite

Matts-MacBook:Python matt$ sudo easy_install MySQL-python 
Searching for MySQL-python 
Reading https://pypi.python.org/simple/MySQL-python/ 
Best match: MySQL-python 1.2.5 
Downloading https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-   1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c 
Processing MySQL-python-1.2.5.zip 
Writing /tmp/easy_install-i14rIs/MySQL-python-1.2.5/setup.cfg 
Running MySQL-python-1.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-i14rIs/MySQL- python-1.2.5/egg-dist-tmp-mG9d4K 
clang: warning: -framework CrashReporterSupport: 'linker' input unused 
In file included from _mysql.c:44: 
/usr/local/mysql/include/my_config.h:349:11: warning: 'SIZEOF_SIZE_T' macro redefined 
#define SIZEOF_SIZE_T SIZEOF_LONG 
    ^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:56:17: note: 
    previous definition is here 
#  define SIZEOF_SIZE_T   4 
^In file included from _mysql.c:44: 
/usr/local/mysql/include/my_config.h:443:9: warning: 'HAVE_WCSCOLL' macro redefined 
#define HAVE_WCSCOLL 
    ^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:912:9: note: 
    previous definition is here 
#define HAVE_WCSCOLL 1 
    ^
_mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false 
    [-Wtautological-compare] 
    if (how < 0 || how >= sizeof(row_converters)) { 
     ~~~^~ 
3 warnings generated. 
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.Internal.sdk/System/Library/PrivateFrameworks' 
ld: framework not found CrashReporterSupport 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
error: Setup script exited with error: command 'cc' failed with exit status 1 
+0

Come punto minore della realtà, MySQL-python sembra essere abbandonato dal proprietario del progetto unica e non supporta Python 3 (sebbene ci siano forchette compatibili con Py3). Sta usando il pacchetto [mysql-connector-python] supportato da Oracle (https://pypi.python.org/pypi/mysql-connector-python) (funziona con Python 2 e 3) un'opzione? –

risposta

14

Ho risolto il problema nel modo seguente:

  1. Dopo aver installato il OSX command line tools, per installare il MySQL-python.

    $ xcode-select --install

    $ sudo pip install MySQL-python

    (Tre messaggio di avviso viene emesso, ma, "installato con successo MySQL-python" ...)

  2. "import MySQLdb" errore dal interprete Python (" immagine non trovato" errore) è stato risolto nel modo seguente:

    $ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/

Il mio ambiente, "OSX Yosemite, mysql 5.6.21, Python 2.7.8".

Buona fortuna.

+1

Questo ha risolto l'errore "import MySQLdb" frustrante per me. – python1981

+0

Sì! Grazie, questo funziona alla grande per me. – DuffJ

+1

Dopo aver aggiornato MySQL a 5.7.10 da 5.6.26 su OSX Yosemite, Python 2.7.11 'sudo ln -s /usr/local/Cellar/mysql/5.6.26/lib/libmysqlclient.18.dylib/usr/local/lib/' – ajsmith007

2

Si consiglia di utilizzare pip invece di easy-install, in quanto è la soluzione più avanzata. Vedere here per motivi.

Poiché si verifica anche un errore XCode, probabilmente non sono installati gli strumenti della riga di comando OSX. Sono necessari per la compilazione di MySQL-python. È possibile scaricarli da Apple dopo aver effettuato l'accesso.

Se si dovesse ancora riscontrare un errore, installare mysql-client tramite homebrew. brew install mysql --client-only

+0

Ciao ragazzi, qualcuno aveva risolto questo problema? Ho ancora questo errore: "Ragazzi, chiunque ha risolto questo problema? Ho ancora" – alfdev