Search code examples
pythonpython-3.xmacosvisual-studio-codemacos-monterey

Python3 and 'code' CLI not working after updating to MacOS Monterey


I updated to MacOS Monterey and now python is not working:

➜  ~ python3 --version    
dyld[6578]: dyld cache '/System/Library/dyld/dyld_shared_cache_x86_64h' not loaded: syscall to map cache into shared region failed
dyld[6578]: 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]    6578 abort      python3 --version

But if I run:

➜  ~ /usr/bin/python3 --version
Python 3.8.9

I am able to run it. But when running code . for opening a project in vs code it gives the same error:

dyld[6683]: dyld cache '/System/Library/dyld/dyld_shared_cache_x86_64h' not loaded: syscall to map cache into shared region failed
dyld[6683]: 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)
/usr/local/bin/code: line 10: ./MacOS/Electron: No such file or directory

I am not sure what to do so that it runs commands like code . successfully.


Solution

  • Your python3 is 3.8.9 but the error message is for 3.6. It looks like you have clashing python versions. I fixed this error on my machine by uninstalling 3.6 and all of its syslinks like seen here under "Uninstalling Python 3 Using Terminal", except I used homebrew commands brew doctor and then brew cleanup for steps 4. and 5.