全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 python论坛
2019 1
2017-05-28
1.具体问题描述

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

<ipython-input-21-dd22983d5391> in <module>()

----> 1 import MySQLdb


/Users/squirrel/anaconda/lib/python2.7/site-packages/MySQLdb/__init__.py in <module>()

     17 from MySQLdb.release import __version__, version_info, __author__

     18

---> 19 import _mysql

     20

     21 if version_info != _mysql.version_info:


ImportError: dlopen(/Users/squirrel/anaconda/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libcrypto.1.0.0.dylib

  Referenced from: /Users/squirrel/anaconda/lib/python2.7/site-packages/_mysql.so

  Reason: image not found

就是 python mysqldb Library not loaded: libssl.1.0.0.dylib



2.解决方案
(1)google到了解决方案:(https://stackoverflow.com/questi ... ng-once-python-file
具体如下:

So I discovered I should be working with the libssl.1.0.0.dylib file in /usr/lib, not the file that was mentioned by the error, which was Users/$USERNAME/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so in my case.

I created a symlink to where libssl.1.0.0.dylib should be referenced from, (/Users/$USERNAME/anaconda/lib/ for me), using

sudo ln -s /Users/$USERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib

and, once that's done, the same for libcrypto.1.0.0.dylib, as it threw the same error.

sudo ln -s /Users/$USERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib

As a side note when listing the files in /usr/bin these two are listed as libss.dylib and libcrypto.dylib.


但是出bug了:

sudo ln -s /Users/squirrel/anaconda/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib

ln: /usr/lib/libssl.1.0.0.dylib: Operation not permitted



继续google:(https://stackoverflow.com/questi ... n-rootless-disabled),如下(就是关闭SIP,也就是rootless特性,比较不安全):

Nvm. For anyone else having this problem you need to reboot your mac and press ⌘+R when booting up. Then go into Utilities > Terminal and type the following commands:

csrutil disablereboot


(3)继续解决
将上面本要链接到/usr/bin下的改链接到/usr/local/bin下就好,所以最终的方案如下:

sudo ln -s /Users/squirrel/anaconda/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.1.0.0.dylib


sudo ln -s /Users/squirrel/anaconda/lib/libcrypto.1.0.0.dylib  /usr/local/lib/libcrypto.1.0.0.dylib





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-6-4 06:40:29
15884579436 发表于 2017-5-28 11:04
1.具体问题描述---------------------------------------------------------------------------ImportError ...
恭喜
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群