1

最近,我执行了 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,还是你认为这是一个更深层次的问题?

4

1 回答 1

0

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

于 2013-02-14T21:31:14.590 回答