8

I'm getting this error when trying to use python 3. How can I solve this issue?

dyld[2675]: dyld cache '/System/Library/dyld/dyld_shared_cache_x86_64h' not loaded: syscall to map cache into shared region failed dyld[2675]: 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)

chackerian
  • 1,301
  • 2
  • 15
  • 29

2 Answers2

9

This looks like you've got multiple installations of Python 3 that may have carried over from a previous macOS upgrade. If you directly type /usr/bin/python3 and don't get an error then this is likely an issue with a homebrew/macports/something else custom installation. You can type which python3 to see what it would execute by default when just using python3, but the fix depends on what you've done to your system. Check dyld: Library not loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation for more help.

Paul Kehrer
  • 13,466
  • 4
  • 40
  • 57
  • `which python3` returns: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3. I guess that is a bad version. I have tried using /usr/bin/python3 to run my file but this gives an error that I don't have a package installed. When I run pip list the package is there. – chackerian Jan 22 '22 at 17:16
  • It looks like you may have some incorrect mental models of how Python manages packages and how pathing works for shells in Unix-like OSes. I'd highly suggest spending some time learning a bit about that and how virtual environments work so that you can more effectively isolate your own projects from global packages or the system itself. – Paul Kehrer Jan 22 '22 at 20:27
  • 1
    Thanks for this answer! The link to the other question explained what happened on my machine exactly (macOS -> updated to monterey and got a new version of python3). I have installed way too many python environments directly so deleting some of them from /Library/Frameworks/Python.framework/Versions solved the problem. – ngood97 May 13 '22 at 04:28
0

It happened because the new macos installed a newer version of python3 and was not able to connect to the existing older version. I could solve it by looking under /Library/Frameworks/Python.framework/Versions and updating the pointed python3 version (as current) in my interpreter settings within pycharm ide.