這兩個error都出現(xiàn)在執(zhí)行command script import ...時。
報錯1 :
error描述:
在lldb中執(zhí)行命令
command script import "/Library/Developer/KDKs/KDK_10.11.3_15D21.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/DWARF/../Python/lldbmacros/xnu.py"
報錯如下:
error: module importing failed: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so, 2): Symbol not found: __PySlice_AdjustIndices
解決方法:
問題就出在這個_ctypes.so上。在terminal中執(zhí)行sudo find / -name _ctypes.so
輸出如下:
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
其中第四行是這個報錯的文件,第三行是系統(tǒng)自帶文件。將第四行的文件備份后,用第三行文件的文件覆蓋它。
cp /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
報錯2 :
error描述 :
依然是執(zhí)行 command script import時報錯:
error: module importing failed: No module named logging
File "temp.py", line 1, in <module>
File "/Library/Developer/KDKs/KDK_10.11.3_15D21.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/DWARF/../Python/lldbmacros/xnu.py", line 757, in <module>
from usertaskgdbserver import *
File "/Library/Developer/KDKs/KDK_10.11.3_15D21.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/DWARF/../Python/lldbmacros/usertaskgdbserver.py", line 2, in <module>
import logging
解決方法:
參考這個鏈接里的回答:
...but because this question appears high in search results for the error, I wanted to say that I had this error on OSX because my default system Python was 2.7, and I brew installed "python@2" while installing another package.
If you're on OSX and are using homebrew, check your packages installed with brew by running brew list, and if "python@2" appears in that list, and Python 2.7 is your system Python, you can remove the brew installed package with brew remove python@2 --ignore-dependencies
先通過brew list查看是否通過homebrew安裝了"python@2",如果有,執(zhí)行brew remove python@2 --ignore-dependencies。
然后就可以開始愉快滴調(diào)試啦