{"id":1579,"date":"2011-01-25T19:57:02","date_gmt":"2011-01-26T03:57:02","guid":{"rendered":"http:\/\/www.curlybrace.com\/words\/?p=1579"},"modified":"2011-01-25T19:57:46","modified_gmt":"2011-01-26T03:57:46","slug":"mac-os-mysql-python-1-2-3-importerror-library-not-loaded-libmysqlclient-16-dylib","status":"publish","type":"post","link":"https:\/\/www.curlybrace.com\/words\/2011\/01\/mac-os-mysql-python-1-2-3-importerror-library-not-loaded-libmysqlclient-16-dylib\/","title":{"rendered":"Mac OS + MySQL-python-1.2.3:  ImportError | Library not loaded | libmysqlclient.16.dylib"},"content":{"rendered":"<p>Attempting to get Python communicating with MySQL via <a href=\"http:\/\/sourceforge.net\/projects\/mysql-python\/\">MySQLdb<\/a> on OS X resulted in the following error when I tried to <tt>import MySQLdb<\/tt>:<\/p>\n<blockquote>\n<pre class=\"bash\">Traceback (most recent call last):\r\n  File \".\/dbtest.py\", line 3, in <module>\r\n    import MySQLdb\r\n  File \"build\/bdist.macosx-10.6-universal\/egg\/MySQLdb\/__init__.py\", line 19, in <module>\r\n  File \"build\/bdist.macosx-10.6-universal\/egg\/_mysql.py\", line 7, in <module>\r\n  File \"build\/bdist.macosx-10.6-universal\/egg\/_mysql.py\", line 6, in __bootstrap__\r\nImportError: dlopen(\/Users\/fitzsimj\/.python-eggs\/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp\/_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib\r\n  Referenced from: \/Users\/fitzsimj\/.python-eggs\/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp\/_mysql.so\r\n  Reason: image not found<\/pre>\n<\/blockquote>\n<p>I eventually found a solution mentioned <a href=\"http:\/\/stackoverflow.com\/questions\/4546698\/library-not-loaded-libmysqlclient-16-dylib-error-when-trying-to-run-rails-serve\">here<\/a>.  I added the following line to <tt>\/etc\/bashrc<\/tt>:<\/p>\n<blockquote>\n<pre class=\"bash\">export DYLD_LIBRARY_PATH=\/usr\/local\/mysql\/lib\/<\/pre>\n<\/blockquote>\n<p>There is another solution suggested, using <tt>install_name_tool<\/tt>.  That approach involves Ruby, which I&#8217;m not using.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Attempting to get Python communicating with MySQL via MySQLdb on OS X resulted in the following error when I tried to import MySQLdb: Traceback (most recent call last): File &#8220;.\/dbtest.py&#8221;, line 3, in import MySQLdb File &#8220;build\/bdist.macosx-10.6-universal\/egg\/MySQLdb\/__init__.py&#8221;, line 19, in &hellip; <a href=\"https:\/\/www.curlybrace.com\/words\/2011\/01\/mac-os-mysql-python-1-2-3-importerror-library-not-loaded-libmysqlclient-16-dylib\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-1579","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts\/1579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/comments?post=1579"}],"version-history":[{"count":4,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts\/1579\/revisions"}],"predecessor-version":[{"id":2089,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts\/1579\/revisions\/2089"}],"wp:attachment":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/media?parent=1579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/categories?post=1579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/tags?post=1579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}