2012-11-18 3 views
12

Hier ist mein Problem: Ich kann nicht MySQLdb für Python arbeiten. Die meisten anderen Beiträge zu diesem Thema haben unterschiedliche Architekturen von MySQL/Python genannt. Ich überprüfte, und sie sind beide 64 Bit. Ich habe Python 2.7.2 (Standard OS X) und das neueste MySQL, OS X 10.8.2.MySQLdb für Python 2.7 auf OSX 10.8.2 und BEIDE sind 64 Bit

meiner ursprünglichen Fehlerprotokolle:

Der Versuch, MySQL DB zu importieren, gibt mir diese Fehlermeldung:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/__init__.py", line 19, in <module> 
    import _mysql 
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib 
    Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so 
    Reason: image not found 

Dies könnte auch die Ausgabe der Konsole hilfreich sein, während ich mysql-Python 1.2 installieren. 4b4

xxx-MBP:MySQL-python-1.2.4b4 me$ sudo python setup.py clean 
running clean 
removing 'build/temp.macosx-10.8-intel-2.7' (and everything under it) 
xxx-MBP:MySQL-python-1.2.4b4 me$ sudo python setup.py install 
running install 
running bdist_egg 
running egg_info 
writing MySQL_python.egg-info/PKG-INFO 
writing top-level names to MySQL_python.egg-info/top_level.txt 
writing dependency_links to MySQL_python.egg-info/dependency_links.txt 
writing MySQL_python.egg-info/PKG-INFO 
writing top-level names to MySQL_python.egg-info/top_level.txt 
writing dependency_links to MySQL_python.egg-info/dependency_links.txt 
reading manifest file 'MySQL_python.egg-info/SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
writing manifest file 'MySQL_python.egg-info/SOURCES.txt' 
installing library code to build/bdist.macosx-10.8-intel/egg 
running install_lib 
running build_py 
copying MySQLdb/release.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb 
running build_ext 
creating build/bdist.macosx-10.8-intel/egg 
copying build/lib.macosx-10.8-intel-2.7/_mysql.so -> build/bdist.macosx-10.8-intel/egg 
copying build/lib.macosx-10.8-intel-2.7/_mysql_exceptions.py -> build/bdist.macosx-10.8-intel/egg 
creating build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/__init__.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/connections.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
creating build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/release.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/times.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
byte-compiling build/bdist.macosx-10.8-intel/egg/_mysql_exceptions.py to _mysql_exceptions.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py to __init__.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/connections.py to connections.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/__init__.py to __init__.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/CR.py to CR.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/ER.py to ER.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/FLAG.py to FLAG.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/converters.py to converters.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/cursors.py to cursors.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/release.py to release.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/times.py to times.pyc 
creating stub loader for _mysql.so 
byte-compiling build/bdist.macosx-10.8-intel/egg/_mysql.py to _mysql.pyc 
creating build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
writing build/bdist.macosx-10.8-intel/egg/EGG-INFO/native_libs.txt 
zip_safe flag not set; analyzing archive contents... 
creating 'dist/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg' and adding 'build/bdist.macosx-10.8-intel/egg' to it 
removing 'build/bdist.macosx-10.8-intel/egg' (and everything under it) 
Processing MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 
removing '/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg' (and everything under it) 
creating /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 
Extracting MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg to /Library/Python/2.7/site-packages 
MySQL-python 1.2.4b4 is already the active version in easy-install.pth 

Installed /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 
Processing dependencies for MySQL-python==1.2.4b4 
Finished processing dependencies for MySQL-python==1.2.4b4 
+0

Interessanter Hinweis, ich habe meine Installation gereinigt und folgte dann diesen (http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os /) Richtungen (der Macports Teil funktionierte nicht für mich), speziell baute ich mit 64bit Flags während des Build-Prozesses neu und dann neu installiert. JETZT ETWAS WIERD HAPPENS. Importieren Sie MySQLdb WORKS aus dem Terminal, aber nicht aus einem Code-Editor. – Tizzee

+0

Auch der Hinweis,/Bibliothek/Python enthält Ordner für 2.3, 2.4, 2.5, 2.6 und 2.7, aber die 2.7 hat Zeug drin. WITHIN 2.7 (/library/python/2.7/) Ich habe mehrere Egg-Dateien, eine MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg UND eine MySQL_python-1.2.4b4-py2.7-macosx -10.8-x86_64.egg, und beide von denen haben die gleichen Dateien in ihnen ... sollte ich einen löschen? welchen sollte ich behalten? Ich bin so extrem frustriert Jungs. – Tizzee

+0

AUCH VON ANMERKUNG: Wenn ich Kontrolle- | während in Python in Terminal, es endet, aber ich bekomme ein OSX-Fenster, das Python unerwartet beendet sagt. – Tizzee

Antwort

13

Ich denke, ich habe es! Hier ist was ich getan habe.

OK, das war extrem frustrierend.

Was es Arbeit dies schließlich gemacht im Terminal tat:

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

Aber es gab eine Menge anderer Sachen davor. Ich mischte die Anweisungen aus zwei Quellen:

How to install MySQLdb (Python data access library to MySQL) on Mac OS X? und http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/

verwenden ich die ersten Python reinigen und die Build-Dateien zu ändern ... habe ich die zweiten 64-Bit-Flags hinzufügen zu installieren und zu bauen ...

Dann habe ich eine Antwort auf Error importing MySQLdb in Python 2.7.2 on Mac OSx 10.8.1 (das ist die letzte Sache war, dass es Arbeit gemacht.)

mich über den Rand zu setzen.

Ich bin mir nicht sicher, was genau einen Unterschied gemacht hat, weil ich SO VIELE DINGE gemacht habe. Ich habe eine Menge Sachen aus dem 2.7 Python-Ordner gelöscht ... und andere Dinge. Aber das einzige, worauf ich mich verlassen kann, ist, dass die Mischung der Richtungen aus diesen beiden Quellen einen Unterschied machte. Danke für all die Hilfe, Leute ... .lol ich hoffe, dass das jemandem Kopfschmerzen erspart.

0

Ich habe die 4 Konfigurationshindernisse aufgelistet, die ich konfrontiert habe, ich habe sie aufgelistet.

export CFLAGS = -Qunused Argumente Export CPPFLAGS = -Qunused-Argumente Kommandozeilen-Tools von Xcode Präferenzen Installation/downloads sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib/usr /lib/libmysqlclient.18.dylib

Verwandte Themen