On an upgrade or new installation of aws-sam-cli via homebrew, sam --version (and any other sam commands) fails with the error
dyld: Library not loaded: @executable_path/../.Python
Referenced from: /usr/local/Cellar/aws-sam-cli/0.53.0/libexec/bin/python3.7
Reason: image not found
This seems to have something to do with homebrew upgrading Python3 to version 3.8 on any upgrade or install, while sam-cli is looking for specifically version 3.7.
In my case, this happened from trying to upgrade my sam-cli version via brew upgrade aws-sam-cli, but the same issue seems to occur on a new installation via homebrew.
Install (or upgrade) aws-sam-cli via homebrew, as per the instructions at https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html. Run sam --version, or any other sam-cli command.
dyld: Library not loaded: @executable_path/../.Python
Referenced from: /usr/local/Cellar/aws-sam-cli/0.53.0/libexec/bin/python3.7
Reason: image not found
sam --version displays sam-cli version, sam-cli commands work.
sam --version: 0.53.0is there anyway to use a previous version of aws-sam-cli until this is fixed? it seems like only the latest version is available via homebrew
There is a workaround provided here: https://github.com/aws/homebrew-tap/issues/93
Specifically: brew install --build-from-source aws-sam-cli. This will not use the bottle. This will however take much longer to install.
Thanks for the workaround, I'm back in business.
Most helpful comment
There is a workaround provided here: https://github.com/aws/homebrew-tap/issues/93
Specifically: brew install --build-from-source aws-sam-cli. This will not use the bottle. This will however take much longer to install.