Python 如何解决“dyld:库未加载:@executable_path ..”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47629570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to resolve "dyld: Library not loaded: @executable_path.." error
提问by Manogna Mujje
I was trying to check the AWS-CLI version on my MAC OS X. And the below error hit back:
我试图在我的 MAC OS X 上检查 AWS-CLI 版本。并且出现以下错误:
dyld: Library not loaded: @executable_path/../.Python
Referenced from: /usr/local/aws/bin/python
Reason: image not found
Abort trap: 6
Any relevant inputs on how to fix this would be highly appreciated.
任何有关如何解决此问题的相关意见将不胜感激。
回答by Abdennour TOUMI
It is a bug with awscli and it might be fixed with the next versions. That's why, a best practices is to upgrade :
这是 awscli 的一个错误,可能会在下一个版本中修复。这就是为什么,最佳实践是升级:
brew upgrade awscli
回答by Nabin
You must have messed up with the brew. Try reinstalling it using: brew install awscli
(followed by brew link awscli
if needed).
你一定搞砸了酿造。尝试使用以下方法重新安装它:(如果需要,请brew install awscli
跟随brew link awscli
)。
回答by Sant
This error occurs because your virtual environment has broken symlinks.
Here is a nice solution taken from tevino's fix_virtualenv
gist:
出现此错误是因为您的虚拟环境已损坏符号链接。这是取自tevino's fix_virtualenv
gist 的一个很好的解决方案:
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
BAD_ENV_PATHS="/usr/local"
echo "Ensure the root of the broken virtualenv:"
echo " $ENV_PATH"
if [[ -z "$ENV_PATH" ]] || [[ "$ENV_PATH" = *"$BAD_ENV_PATHS"* ]]; then
echo "The root path above doesn't seems to be a valid one."
echo "Please make sure you ACTIVATED the broken virtualenv."
echo "?? Exiting for your safety... (thanks @laymonk for reporting this)"
exit 1
fi
read -p "?? Press Enter if you are not sure (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "?? Removing old symbolic links......"
find "$ENV_PATH" -type l -delete -print
echo " Creating new symbolic links......"
$SYSTEM_VIRTUALENV "$ENV_PATH"
echo " Done!"
fi
Also, here is a similar question: Broken references in Virtualenvs.
另外,这里有一个类似的问题: 在 Virtualenvs 中损坏的引用。
回答by Zaur
I had similar issue while installing awscli with homebrew on mac. So final approach was "brew uninstall python3" and reinstall awscli again.
我在 mac 上使用自制软件安装 awscli 时遇到了类似的问题。所以最后的方法是“brew uninstall python3”并再次重新安装awscli。
回答by Gleb Belyaev
After read the topic, It works for me:
阅读主题后,它对我有用:
- Uninstall aws
- 卸载 aws
$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws
- Reinstall it again
- 重新安装一遍
$ brew reinstall awscli
回答by Alona Honcharova
If you have already python (python --versionworks. If not install it with brew install python). It works for me:
如果你已经有 python (python --version工作。如果没有安装它brew install python)。这个对我有用:
Uninstall aws
$ sudo rm -rf /usr/local/aws $ sudo rm /usr/local/bin/aws
Install it again
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" $ unzip awscli-bundle.zip $ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
卸载 aws
$ sudo rm -rf /usr/local/aws $ sudo rm /usr/local/bin/aws
重新安装
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" $ unzip awscli-bundle.zip $ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
回答by Hamdi Al-Haj
I had it installed through curl, the regular way
我通过常规方式通过 curl 安装了它
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
Then it stopped working complaining about not finding python2.7
然后它停止工作抱怨找不到 python2.7
dyld: Library not loaded: @executable_path/../.Python
Referenced from: /usr/local/aws/bin/python2.7
Reason: image not found
Abort trap: 6
so I fixed it by following these steps (make sure you don't do this if you installed it through brew
):
所以我按照以下步骤修复了它(如果你通过 安装它,请确保你不要这样做brew
):
$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws
Then I installed it using brew:
然后我使用 brew 安装它:
$ brew upgrade
$ brew install awscli
回答by Will Cain
It's possible to trigger this error by having a problem in your virtualenv. For example, I had an existing working virtualenv and ran brew install awscli
and it broke my virtualenv with this error. If that's the case, deleting and recreating your virtualenv (the same way you originally created it) should resolve the problem. It did for me.
如果您的 virtualenv 出现问题,可能会触发此错误。例如,我有一个现有的工作 virtualenv 并运行brew install awscli
它并因此错误而破坏了我的 virtualenv。如果是这种情况,删除并重新创建您的 virtualenv(与您最初创建它的方式相同)应该可以解决问题。它对我有用。