Can't find Python modules after Time Machine restore

739 Views Asked by At

Recently, I performed a clean install of OS X Mountain Lion and restored my system from a Time Machine backup. When I tried to use python, it was unable to find most of the modules that I had installed before I wiped my OS. It also appears that the Xcode Command Line Tools were no longer on the system.

I reinstalled the Xcode Command Line Tools and pip (using easy_install), and went to work reinstalling the modules I use, starting with numpy. However, pip said it was already installed:

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

However, in the CLI for Python, it still can't find 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

I've tried to install some other modules. When I installed ujson with pip, everything went fine, and python found it with no problems. However, when I tried to install matplotlib with pip, clang threw an error and it failed to install. I think the problem might be that matplotlib has dependency on numpy, but I don't know.

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`

Any advice on how to resolve this issue? Should I just uninstall this other version of numpy, or do you think this is a deeper issue?

1

There are 1 best solutions below

0
On

Deleting the numpy files in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python and reinstalling numpy would be my suggestion. It seems like the libraries are no longer being linked to properly even though the files are there.