首页
pydev Pycharm 加载attach_x86_64.dylib错误

问题

PyCharm调试程序出现:Error loading: /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_x86_64.dylib 错误提示。

解决

使用file 命令查看文件信息,发现是x86的库导致

file /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process//attach_x86_64.dylib
pydevd_attach_to_process/attach_x86_64.dylib: Mach-O 64-bit dynamically linked shared library x86_64

此动态库是由/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux_and_mac/compile_mac.sh 脚本编译出来的,

所以我们查看脚本内容,要修改 -arch 参数 ,将 x86_64 修改为 arm64 重新编译即可
进入/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux_and_mac 目录

执行如下命令:

g++ -fPIC -D_REENTRANT -std=c++11 -arch arm64 -c -o attach_x86_64.o attach.cpp

g++ -dynamiclib -nostartfiles -arch arm64 -o attach_x86_64.dylib attach_x86_64.o -lc

rm attach_x86_64.o

mv attach_x86_64.dylib ../attach_x86_64.dylib

重新执行调试,问题解决