I'm using Django, and when I run python manage.py runserver
I receive the following error:
ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/_mysql.so
Reason: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Python/2.7/site-packages/_mysql.so with restricted binary
I'm not entirely sure how to fix this. I have installed MySQL-python via pip. And I followed this step earlier.
I want to also point out this is with El Capitan Beta 3.
If there are lots of relative paths to be fixed for something (as happened with me for opencv library). You can use the following snippet:
Change the ABSPATH and LIBPATHS accordingly. It will create rPathChangeCmd.txt which you can paste in the terminal. It will also create rPathChangeErr.txt in case of any errors. I would suggest check error file (if created) before pasting the commands.
In OS X El Capitan (10.11), Apple added System Integrity Protection.
This prevents programs in protected locations like
/usr
from calling a shared library that uses a relative reference to another shared library. In the case of_mysql.so
, it contains a relative reference to the shared librarylibmysqlclient.18.dylib
.In the future, the shared library
_mysql.so
may be updated. Until then, you can force it to use an absolute reference via theinstall_name_tool
utility.Assuming that
libmysqlclient.18.dylib
is in /usr/local/mysql/lib/, then run the command: