https://www.jianshu.com/p/4968e2585a94
具体报错:
dyld: Library not loaded: /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/Python
Referenced from: /usr/local/bin/python
Reason: image not found
具体原因是,以前Mac上安装了 python3/3.6.3
, 现在安装的版本是 python3/3.6.5
,原来的 3.6.3 版本的路径(/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/Python
) 不存在了,导致每次使用terminal的时候都会提示python3.6.3 加载失败
python not load错误.png
使用下面命令解决这个问题:
# 查看python所在的位置
> which python
输出:
/usr/local/bin/python
# 查看 /usr/local/bin/python 的依赖
> otool -L /usr/local/bin/python
输出:
/usr/local/bin/python:
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/Python (compatibility version 3.6.0, current version 3.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
可以看出依赖3.6.3已经写死了
# 将 /usr/local/bin/python 的依赖更改为当前版本python的路径
# 更改为当前python3.6.5的路径
> install_name_tool -change /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/Python /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/Python /usr/local/bin/python
修改完成之后就不会再报这个错误了
参考文章: