楼主: 15884579436
2049 1

[其他] mac:import MySQLdb errors [推广有奖]

  • 4关注
  • 2粉丝

已卖:449份资源

讲师

8%

还不是VIP/贵宾

-

威望
0
论坛币
579 个
通用积分
72.4038
学术水平
3 点
热心指数
2 点
信用等级
0 点
经验
12539 点
帖子
327
精华
0
在线时间
275 小时
注册时间
2012-10-4
最后登录
2025-8-10

楼主
15884579436 发表于 2017-5-28 11:04:52 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
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





二维码

扫码加我 拉你入群

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

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

关键词:import Errors Error MySQL Port errors import python loaded

开心就好

沙发
phoenixlqh 学生认证  发表于 2017-6-4 06:40:29 来自手机
15884579436 发表于 2017-5-28 11:04
1.具体问题描述---------------------------------------------------------------------------ImportError ...
恭喜

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 02:46