标签:安全模式 mac python mysql os 10.11
最近在mac下安装mysqldb-python搞的好麻烦,为了避免这个坑,先记下来再讲!
首先重启mac,长按cmd+R,进入恢复模式,然后依次点击应用-》终端,然后输入csrutil disable,究其原因,是因为某些库文件mac为了安全不让写入,所以,必须把安全模式关闭;然后启动mac;
然后
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.11-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.11-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.11-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/zhao/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.11-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
unsafe referenced from: /Users/zhao/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.11-intel.egg-tmp/_mysql.so这个问题就解决了,然后再执行import MySQLdb
还是会报错,
ImportError: dlopen(/Users/zhao/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.11-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/zhao/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.11-intel.egg-tmp/_mysql.so
Reason: image not found
3.这时候再执行ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
最终这个问题终于解决了
本文出自 “11869724” 博客,请务必保留此出处http://11879724.blog.51cto.com/11869724/1827898
标签:安全模式 mac python mysql os 10.11
原文地址:http://11879724.blog.51cto.com/11869724/1827898