Reputation: 2724
I've just installed MySQL on my 10.10.1 MAC, and I'm trying to link it to Python. However I get this error when I'm trying to import the package.
import MySQLdb as mdb
File "build/bdist.macosx-10.5-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.5-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.5-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/ME/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/ME/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so
Reason: image not found
[Finished in 0.2s with exit code 1]
I have no idea what "Image not found" means, or how to solve this.
MySQL is connected to the server in the background, and I installed the package through the terminal window using: easy_install MySQL-python
Any suggestions on where I went wrong?
Upvotes: 1
Views: 6811
Reputation: 399
Check where your _mysql.so
is linking to:
otool -L /Library/Python/2.7/site-packages/_mysql.so
In my case I built the mysql source in /tmp/
and once
tmp
cleaned up my dylib
went away. I never re-linked to a
reliable location like /Applications/MAMP/Library/lib
where
my mysql libraries live (because I copied them here after the build).
So I went back and rebuilt everything and made sure to run the command to
update the package link to the correct dylib
:
sudo install_name_tool -change <temp file location>/mysql-5.5.29/libmysql/libmysqlclient.18.dylib /Applications/MAMP/Library//lib/libmysqlclient.18.dylib /Library/Python/2.7/site-packages/_mysql.so
I followed the setup found here: http://dreamconception.com/tech/how-to-install-mysqldb-mysql-python-on-mamp/
NOTE: That I didn't need to do the step regarding changing the configure.cmake
file. When I looked at the configure.cmake
file it made sense to me so I ran
it as-is and it worked.
Also note your libmysqlclient.<num>.dylib
might be something different so
do a find . -name "libmysqlclient.*.dylib"
to get the right one
Now re-run the otool
command and see that the linking was updated.
References (and other solutions):
Upvotes: 3
Reputation: 1525
The solution to the problem can be found in this link Python: MySQLdb and "Library not loaded: libmysqlclient.16.dylib"
_mysql.so refers to libmysqlclient.16.dylib. That is, the shared library that serves as the bridge between Python and the MySQL client library, _mysql.so, refers to the dynamic library for the MySQL client library, and that library cannot be loaded for some reason.
Questions you need to answer:
Is there a libmysqlclient.16.dylib anywhere on your system? If not, you need to install the MySQL client software.
If so, is the directory containing that library in your DYLD_LIBRARY_PATH setting? If not, try adding it.
- If so, you'll have to ensure that the libmysqlclient.16.dylib file is not corrupt. My copy, installed in /opt/local/lib/mysql5/mysql/libmysqlclient.16.dylib, courtesy of MacPorts, has MD5 signature c79ee91af08057dfc269ee212915801a and is 1,462,376 bytes in size. What does your copy look like?
Upvotes: 1