博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 2.7.10 找不到 libmysqlclient.18.dylib 解决方案
阅读量:6801 次
发布时间:2019-06-26

本文共 1956 字,大约阅读时间需要 6 分钟。

   Mac os x 升级到最新版后出现 python MysqlDB 无法找到 libmysqlclient.18.dylib 的问题,尝试的解决方案如下:

      1.  升级更新 mysql 到最新版,无效;

      2.  升级 python mysqlDB 到最新版,无效;

      3.  将 libmysqlclient.18.dylib 重新软链接到 /usr/local/mysql/lib/ libmysqlclient.20.dylib 仍然无效;

 

  在 stackoverflow 上找到一个解决方案,最终问题得到解决,如下:

  http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib

 

    

My preferred method is to actually fix the library rather than playing with environment variables that may or may not actually be in scope depending on how the application is run. This is actually a fairly simple process.

First, look at the error output to see where the offending python module is located:

ImportError: 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: image not found

Okay, so the offending file is /Library/Python/2.7/site-packages/_mysql.so

Next, figure out where _mysql.so thinks it should find libmysqlclient.18.dylib:

% otool -L /Library/Python/2.7/site-packages/_mysql.so /Library/Python/2.7/site-packages/_mysql.so: libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

So, it's looking for libmysqlclient.18.dylib with no path information, let's fix that:

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

Now _mysql.so knows the full path to the library and everything works, regardless of environment variables.

% otool -L /Library/Python/2.7/site-packages/_mysql.so /Library/Python/2.7/site-packages/_mysql.so: /usr/local/mysql/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

转载于:https://www.cnblogs.com/muyiblog/p/5644941.html

你可能感兴趣的文章
hdu 3501(欧拉函数引申)
查看>>
django-request获取数据
查看>>
python的eval、exec函数使用总结
查看>>
js解析与序列化json数据(一)
查看>>
Oracle升级前备份和失败回退
查看>>
学习笔记之PostgreSQL / pgAdmin / Psycopg / PostGIS
查看>>
java设计模式-工厂方法模式
查看>>
SAP RFC通信模式
查看>>
基于jQuery+JSON的省市联动效果
查看>>
NABCD构建APP
查看>>
React 获取 url 参数 —— this.props.match
查看>>
乙佳荣第二次作业
查看>>
request请求的常用属性
查看>>
13-JS中的面向对象
查看>>
[转载]LeetCode: Gray Code
查看>>
优达学城数据分析师纳米学位——知识点总结2
查看>>
.Net 调用中国气象台Web Service
查看>>
BNU 51002 BQG's Complexity Analysis
查看>>
leetcode 7. Reverse Integer
查看>>
VC++6.0 自定义按钮,无标题对话框的拖动方法
查看>>