Python 2.7.10 cannot find the Libmysqlclient.18.dylib solution

Source: Internet
Author: User

After upgrading to the latest version of Mac OS X Python mysqldb cannot find the libmysqlclient.18.dylib problem, try the following solution:

1. Upgrade to update MySQL to the latest version, invalid;

2. Upgrade Python mysqldb to the latest version, invalid;

3. Re-linking Libmysqlclient.18.dylib to/usr/local/mysql/lib/libmysqlclient.20.dylib is still invalid;

Find a solution on StackOverflow and the final problem is resolved as follows:

Http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib

My preferred method is-actually fix the library rather than playing with environment variables Ally be in scope depending on how the application is run. This was actually a fairly simple process.

First, look at the "error output to" where the offending Python module is located:

Importerror:dlopen (/library/python/2.7/site-packages/_mysql.so, 2): Library not Loaded:libmysqlclient.18.dylib Referenced from:/library/python/2.7/site-packages/_mysql.so reason:image not found

Okay, so the offending file is/library/python/2.7/site-packages/_mysql.so

Next, figure out where _mysql.so thinks it should find Libmysqlclient.18.dylib:

%Otool-L/Library/Python/2.7/Site-Packages/_mysql.So/Library/Python/2.7/Site-Packages/_mysql.So:Libmysqlclient.18.dylib  (compatibility version 18.0 0, current version 18.0 . 0)  /usr /lib/libsystem.b. (compatibility version 1.0.0, current version 169.3.< Span class= "lit" >0)            

So, it's looking for libmysqlclient.18.dylib with no path information, let's fix that:

% sudo install_name_tool -change Libmysqlclient. 18.dylib /usr/local< Span class= "pun" >/mysql/lib/ libmysqlclient. 18.dylib /library/ Python/2.7/site-< Span class= "PLN" >packages/_mysql. So                  

Now _mysql.so knows the full path to the library and everything works, regardless of environment variables.

%Otool-L/Library/Python/2.7/Site-Packages/_mysql.So/Library/Python/2.7/Site-Packages/_mysql.So: /Usr/Local/Mysql/Lib/Libmysqlclient.18.dylib  (compatibility version 18.0 0, current version 18.0 . 0)  /usr /lib/libsystem.b. (compatibility version 1.0.0, current version 169.3.< Span class= "lit" >0)            

Python 2.7.10 libmysqlclient.18.dylib solution not found

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.