I built/installed MySQL-python successfully; set DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH" in .bash_profile (OS X Lion). When I execute python from the command line and import MySQLdb, everything is fine.
But when I try to import MySQLdb in IDLE, I get the following:
ImportError:
dlopen(/Users/mstath/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so,
2): Library not loaded: libmysqlclient.18.dylib Referenced from:
/Users/mstath/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so
Reason: image not found
I would like to know if there is something I could configure for IDLE to be able to look in /usr/local/mysql/lib/ to find libmysqlclient.
Installed Python/IDLE through python.org installer; no package managers.
You are likely launching IDLE via the
IDLE.appapplication bundle, for example, by double-clicking on the IDLE icon. On OS X, GUI apps launched this way do not use a shell, like bash, and thus.bash_profileis not executed for them. While there are other ways to work around this, the simplest way in this case is to launch IDLE from a shell command line in a terminal window rather than fromIDLE.app. Something like this should work if you used the default install options:or
You can also use a specific version number if you have multiple Python versions installed locally: