mac os python3 报错dyld: Library not loaded

最近使用brew upgrade更新东西后再运行python就这样了

dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/user/work/env/bin/python
  Reason: image not found

查了下资料发现是Homebrew更新python时让virtualenv的软链错位了.
解决方法是重新生成virtualenv对python的软链.

先退出virtualenv

[venv] ~/src/my_app: deactivate

确认删除virtualenv环境错位的软链

~/src/my_app: find venv -type l -delete

再次生成virtualenv环境

~src/my_app: virtualenv venv
~src/my_app: source venv/bin/activate

参考链接:
http://www.jeremycade.com/python/osx/homebrew/2015/03/02/fixing-virtualenv-after-a-python-upgrade/
https://stackoverflow.com/questions/23233252/broken-references-in-virtualenvs

猜你喜欢

转载自blog.csdn.net/qq624202120/article/details/92419816