Python3 报错 dyld cache '/System/Library/dyld/dyld_shared_cache_x86_64h' not loaded: syscall to map cache into shared region failed

在执行 Python3 命令的时候报如下错误:

1
2
3
4
5
6
$ python3
dyld[44774]: dyld cache '/System/Library/dyld/dyld_shared_cache_x86_64h' not loaded: syscall to map cache into shared region failed
dyld[44774]: Library not loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
Reason: tried: '/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation' (no such file), '/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation' (no such file)
[1] 44774 abort python3

估计是 Python 版本有问题,自 macOS Monterey 12.3 后,Python 2 已经从系统移除,安装命令行开发者工具后会自动安装 Python 3,那就可以换成 macOS 的 Python3 试试。