Home > Database > Mysql Tutorial > body text

Why Can\'t I Import MySQLdb on Mac OS X Lion?

Patricia Arquette
Release: 2024-10-29 18:34:16
Original
175 people have browsed it

 Why Can't I Import MySQLdb on Mac OS X Lion?

MySQL-Python Installation Issues on Mac OS X Lion

This query addresses the difficulties encountered when attempting to import MySQLdb after successfully installing MySQL, Python, and mysql-python. The user experiences an "ImportError" indicating that the appropriate image for the "_mysql.so" file cannot be found.

Possible Solutions:

1. Override the Environment:

Modify the DYLD_LIBRARY_PATH environment variable to direct the linker to the location of the ".so" files. Ensure that the path to the installed MySQL library is specified.

2. Utilize Homebrew:

Alternatively, consider using Homebrew, a package manager for macOS. Install Python, MySQL, and mysql-python with the following commands:

<code class="bash">brew install python
brew install mysql
/usr/local/share/python/easy_install mysql-python</code>
Copy after login

Ensure that you add "/usr/local/bin" and "/usr/local/share/python" to your PATH to make the changes permanent.

The above is the detailed content of Why Can\'t I Import MySQLdb on Mac OS X Lion?. 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