Home > Database > Mysql Tutorial > body text

Why am I getting 'Library not loaded: libmysqlclient.16.dylib' when importing MySQLdb on Mac OS 10.6?

Mary-Kate Olsen
Release: 2024-11-06 16:49:02
Original
240 people have browsed it

Why am I getting

Python ImportError: Library Not Loaded on Mac 10.6

Issue:

When importing MySQLdb into a Python terminal on Mac OS 10.6, you encounter an error: "Library not loaded: libmysqlclient.16.dylib."

Resolution:

To resolve this issue, you can apply the following workaround specific to Python:

  1. Install MySQL: Download and install MySQL 5.5.8 following the official instructions.
  2. Install MySQLdb: Download and install the MySQLdb Python plugin.
  3. Check DYLD_LIBRARY_PATH: Verify that /usr/local/mysql/lib is added to $DYLD_LIBRARY_PATH.
  4. Create Symbolic Links: Create symbolic links as follows:

    sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
    sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
    Copy after login
  5. Rebuild MySQLdb: Remove any existing Python egg files for MySQLdb and rebuild them.

Additional Notes:

  • Ensure that you are using the correct version of libmysqlclient.dylib, corresponding to your installed MySQL version.
  • Check the output of "otool -DX /usr/local/mysql/lib/libmysqlclient.16.dylib" to verify that there are no missing dependencies.

The above is the detailed content of Why am I getting 'Library not loaded: libmysqlclient.16.dylib' when importing MySQLdb on Mac OS 10.6?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!