【问题标题】:messed up my system python搞砸了我的系统python
【发布时间】:2015-07-21 15:10:39
【问题描述】:

我搞砸了我的 osx 10.10 系统 python。 Versions 文件夹现在具有非标准结构,从而导致问题。有什么办法可以在不恢复出厂设置的情况下解决这个问题?

$ /System/Library/Frameworks/Python.framework/Versions/bin/python
dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/2.7/Python
  Referenced from: /System/Library/Frameworks/Python.framework/Versions/bin/python
  Reason: image not found
Trace/BPT trap: 5

【问题讨论】:

  • 你是怎么到那里的?
  • 我愚蠢地关注了一篇博文,告诉我要乱用系统 python...我再也找不到它了...

标签: python macos system dyld


【解决方案1】:

这不是位于/System/Library 中的系统 Python(OSX 内置的那个)。

/Library 中的那个是你之后安装的,使用官方的Python distribution 或者可能是 MacPorts 或 Homebrew。

要验证您正在运行操作系统提供的 python,请运行

which python

应该是

/usr/bin/python

如果不是,请检查您的 $PATH 变量。

还要检查你的 PYTHONPATH

python -c "import sys;print sys.path"

确保它确实包含 /System/Library/Frameworks/Python.framework/... 并且没有 /Library/Frameworks/Python.framework/... 条目。

请注意,默认站点包位于/Library/Python/...

一旦您验证了这一点,您就可以卸载(或重新安装)损坏的 Python 分发版(首先执行 pip freeze > requirements.txt 以重新安装任何第三方的东西)。

【讨论】:

  • 看起来我的系统 python 以某种方式链接到 /Library
  • 检查我更新的答案。我认为您运行的是错误的 Python,而不是系统的。
  • 感谢您对此进行调查。我结束了恢复出厂设置,但我会将其留给将来可能遇到此问题的其他人(包括我自己)
猜你喜欢
  • 1970-01-01
  • 2013-04-20
  • 1970-01-01
  • 2020-10-13
  • 1970-01-01
  • 2018-04-02
  • 1970-01-01
  • 2014-01-16
  • 1970-01-01
相关资源
最近更新 更多