Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

python - MySQL Improperly Configured Reason: unsafe use of relative path

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 library libmysqlclient.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 the install_name_tool utility.

Assuming that libmysqlclient.18.dylib is in /usr/local/mysql/lib/, then run the command:

sudo install_name_tool -change libmysqlclient.18.dylib 
  /usr/local/mysql/lib/libmysqlclient.18.dylib 
  /Library/Python/2.7/site-packages/_mysql.so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...