安装lldb插件(https://github.com/snare/voltron/wiki/Installation)后,lldb启动报错:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
搜素了一下大概明白了原因。macOS自带的python verison是2.7.10,在/usr/bin/python。而通过brew安装的python名是python@2,在/usr/local/bin/python。两个python用到的pip包不同。网友提供的办法大多是remove python@2。因此只需要让lldb加载时用系统自带的python即可,修改一下环境变量。
解决方法:
export PATH=/usr/bin:$PATH
# 或 brew remove python@2 --ignore-dependencies
参考:
https://askubuntu.com/questions/981663/python2-7-broken-by-weakref-import-error-please-help