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>
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!