{"id":291,"date":"2011-05-17T16:11:27","date_gmt":"2011-05-17T14:11:27","guid":{"rendered":"http:\/\/web.leinders.de\/harald\/?p=291"},"modified":"2011-07-05T10:11:06","modified_gmt":"2011-07-05T08:11:06","slug":"mysqldb-unter-mac-os-x-snow-leopard","status":"publish","type":"post","link":"https:\/\/www.leinders.de\/harald\/2011\/05\/17\/mysqldb-unter-mac-os-x-snow-leopard\/","title":{"rendered":"MySQLdb unter Mac OS X &#8222;Snow Leopard&#8220;"},"content":{"rendered":"<p>Wenn man unter Mac OS X MySQLdb bauen will, und einen Intel-Mac mit Snow Leopard zusammen mit XCode 4 betreibt, muss man einige H\u00fcrden umschiffen.<\/p>\n<p>1.\u00a0\u00a0\u00a0 Man muss darauf achten, dass Python und MySQL in der gleichen Architektur vorliegen (entweder i386 oder x86_64)<br \/>\n2.\u00a0\u00a0\u00a0 MySQL-python herunterladen und auspacken (http:\/\/pypi.python.org\/pypi\/MySQL-python\/)<br \/>\n3.\u00a0\u00a0\u00a0 Im Default ist das Compile-Target von XCode 10.3. Das funktioniert nicht!<br \/>\n\u2043\u00a0\u00a0\u00a0 export ARCHFLAGS=&#8216;-arch x86_64&#8242;<br \/>\n\u2043\u00a0\u00a0\u00a0 export MACOSX_DEPLOYMENT_TARGET=10.6<br \/>\n4.\u00a0\u00a0\u00a0 Jetzt kann man, wie \u00fcblich, mit python setup.py build und python setup.py install das Paket MySQLdb bauen (siehe README).<\/p>\n<p>Allerdings funktioniert es noch nicht, wenn man versucht, das Modul zu importieren, so wird man mit folgender Fehlermeldung belohnt:<\/p>\n<p><!--more--><\/p>\n<p>Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)<br \/>\n[GCC 4.2.1 (Apple Inc. build 5664)] on darwin<br \/>\nType &#8222;help&#8220;, &#8222;copyright&#8220;, &#8222;credits&#8220; or &#8222;license&#8220; for more information.<br \/>\n&gt;&gt;&gt; import MySQLdb<br \/>\nTraceback (most recent call last):<br \/>\nFile &#8222;&lt;stdin&gt;&#8220;, line 1, in &lt;module&gt;<br \/>\nFile &#8222;build\/bdist.macosx-10.6-intel\/egg\/MySQLdb\/__init__.py&#8220;, line 19, in &lt;module&gt;<br \/>\nFile &#8222;build\/bdist.macosx-10.6-intel\/egg\/_mysql.py&#8220;, line 7, in &lt;module&gt;<br \/>\nFile &#8222;build\/bdist.macosx-10.6-intel\/egg\/_mysql.py&#8220;, line 6, in __bootstrap__<br \/>\nImportError: dlopen(\/Users\/hl\/.python-eggs\/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp\/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib<br \/>\nReferenced from: \/Users\/hl\/.python-eggs\/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp\/_mysql.so<br \/>\nReason: image not found<\/p>\n<p>Entweder liest man hier wirklich mal die Fehlermeldung durch, oder man sucht eben solange, bis man den Fehler hat (wie ich \ud83d\ude42 )<\/p>\n<p>Hintergrund ist, dass das libtool f\u00fcr die Bibliothek libmysqlclient.18.dylib keinen Pfad in der _mysql.o hinterlegt:<\/p>\n<p>$ otool -L _mysql.so<br \/>\n_mysql.so:<br \/>\nlibmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)<br \/>\n\/usr\/lib\/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)<\/p>\n<p>Die L\u00f6sung des ganzen ist relativ simpel;<\/p>\n<p>entweder den Suchpfad anpassen:<br \/>\n$ export DYLD_LIBRARY_PATH=\/usr\/local\/mysql\/lib:$DYLD_LIBRARY_PATH<\/p>\n<p>oder die Dylib fixen (eine Zeile!):<br \/>\n$ install_name_tool -change libmysqlclient.18.dylib \/usr\/local\/mysql\/lib\/libmysqlclient.18.dylib _mysql.so<\/p>\n<p>Danach klappt auch der Modulimport \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wenn man unter Mac OS X MySQLdb bauen will, und einen Intel-Mac mit Snow Leopard zusammen mit XCode 4 betreibt, muss man einige H\u00fcrden umschiffen. 1.\u00a0\u00a0\u00a0 Man muss darauf achten, dass Python und MySQL in der gleichen Architektur vorliegen (entweder i386 oder x86_64) 2.\u00a0\u00a0\u00a0 MySQL-python herunterladen und auspacken (http:\/\/pypi.python.org\/pypi\/MySQL-python\/) 3.\u00a0\u00a0\u00a0 Im Default ist das Compile-Target &hellip; <a href=\"https:\/\/www.leinders.de\/harald\/2011\/05\/17\/mysqldb-unter-mac-os-x-snow-leopard\/\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eMySQLdb unter Mac OS X &#8222;Snow Leopard&#8220;\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[5],"tags":[8],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-systeme","tag-python"],"_links":{"self":[{"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":7,"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/posts\/291\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.leinders.de\/harald\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}