38👍
From your comments, it appears that the libmysqlclient
dylib was installed with a non-absolute library name path. That’s contrary to standard practice on OS X which is different from most other Unix-y systems in this respect. You should be able to permanently fix the problem (at least until your next upgrade) by modifying the path in the .so file by using install_name_tool
or you can make it work by ensuring your Django instance is running with the following environment variable defined:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
You also might be able to get it to work by creating a symlink in /usr/local/lib
to the dylib in /usr/local/mysql/lib
since /usr/local/lib
is on the default dynamic load search path, so (untested!) something like:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
A better long-term solution is to not use a broken MySQL client installation as suggested in Python import MySQLdb error – Mac 10.6.
2👍
Using a homebrew installation of mysql
, this worked for me:
$ mdfind libmysqlclient
/usr/local/Cellar/mysql/5.7.9/lib/libmysqlclient.20.dylib
/usr/local/Cellar/mysql/5.7.9/lib/libmysqlclient.a
/usr/local/Cellar/mysql/5.6.27/lib/libmysqlclient.18.dylib
/usr/local/Cellar/mysql/5.6.27/lib/libmysqlclient.a
/usr/local/Cellar/mysql/5.6.26/lib/libmysqlclient.18.dylib
/usr/local/Cellar/mysql/5.6.26/lib/libmysqlclient.a
$ sudo ln -s /usr/local/Cellar/mysql/5.6.27/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
- Sometimes request.session.session_key is None
- Improving Performance of Django ForeignKey Fields in Admin
1👍
Make sure you have not just MySql-Python, but the actual MySql. MySQL-python is trying to load the mysql library, which should be somewhere like /usr/local/mysql-VERSION/lib.
Try running
mdfind libmysqlclient
on the command line. Scan through those results and if you don’t see the file it’s missing (libmysqlclient.18.dylib) then you probably don’t have mysql installed properly.
- Django admin add custom filter
- How to download a filefield file in django view
- Django admin list_filter – filter field by is empty (None or empty string "")
- Django aggregation: sum then average
- How to specify long url patterns using Regex so that they follow PEP8 guidelines
1👍
You probably have upgraded mysql recently. I got this issue when I upgraded MySql from 5.6 to 5.7 with brew. This definitely broke some libs, but relinking mysql back to 5.6 fixed the issue.
So first see what mysql version you had previously with:
brew info mysql
and after switch back to that version using brew switch mysql 5.6.22
command for example.
- Difference between self.request and request in Django class-based view
- ImportError: cannot import name "urandom"
- How to install pygments on Ubuntu?
0👍
Can you show us your settings.py code?
you can also try edit the path to the mysql_config file to point to /usr/local/mysql/bin/mysql_config as discussed in better detail in this article:
http://dakrauth.com/blog/entry/python-and-django-setup-mac-os-x-leopard/
0👍
I don’t have enough reputation to comment on Ned Deily’s answer above :), but the environment variable method worked for me, after fixing the typo; it should be:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
If you go that route I would suggest two things; make sure you don’t bash any other DYLD_LIBRARY_PATH settings by using
export DYLD_LIBRARY_PATH=$DYLD_LIBARY_PATH:/usr/local/mysql/lib
and put it in your .bashrc file so you don’t have to remember to set it in each terminal session.
The benefit to this method over the symlink option is that it will allow all the mysql dylib files to be found, not just the one(s) you specifically symlink.
- Grouping dates in Django
- Django Rest Framework: Serialize data from nested json fields to plain object