【问题标题】:Can't find Python modules after Time Machine restoreTime Machine 还原后找不到 Python 模块
【发布时间】:2013-01-14 23:59:16
【问题描述】:

最近,我执行了 OS X Mountain Lion 的全新安装,并从 Time Machine 备份恢复了我的系统。当我尝试使用 python 时,它无法找到我在擦除操作系统之前安装的大部分模块。 Xcode 命令行工具似乎也不再在系统上。

我重新安装了 Xcode 命令行工具和 pip(使用 easy_install),然后开始重新安装我使用的模块,从 numpy 开始。但是 pip 说已经安装好了:

Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

但是,在 Python 的 CLI 中,仍然找不到 numpy:

    Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
     >>> import numpy
    Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
    ImportError: No module named numpy

我尝试安装一些其他模块。当我用 pip 安装 ujson 时,一切都很顺利,python 发现它没有问题。但是,当我尝试使用 pip 安装 matplotlib 时,clang 抛出错误并且无法安装。我认为问题可能是matplotlib对numpy的依赖,但我不知道。

In file included from src/ft2font.cpp:3:

src/ft2font.h:16:10: fatal error: 'ft2build.h' file not found

#include <ft2build.h>

         ^

1 error generated.

error: command 'clang' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lqNcmF-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/matplotlib`

关于如何解决此问题的任何建议?我应该卸载这个其他版本的 numpy,还是你认为这是一个更深层次的问题?

【问题讨论】:

  • 更新:我卸载了 /System/Library/... 下的 numpy 版本,现在看来一切正常。这会导致我的电脑出现问题吗?

标签: numpy python-2.7 osx-mountain-lion pip timemachine


【解决方案1】:

我的建议是删除 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 中的 numpy 文件并重新安装 numpy。即使文件在那里,库似乎也不再正确链接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-16
    • 2016-04-30
    • 2012-04-04
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多