Oved D Oved D - 4 months ago 5x
Python Question

fatal error: 'string.h' file not found after upgrading to python 3.2 and installing certain modules from a virtualenv

I'm on Mac OSX 10.8 (Mountain Lion) and have just installed Python 3.2.3.

When installing pycrypto from a virtual environment using that version of python:

$ virtualenv --no-site-packages -p /usr/local/bin/python3.2-32 venv
$ source venv/bin/activate
$ pip install pycrypto

I get the error:

gcc-4.2 not found, using clang instead

building 'Crypto.Hash._MD2' extension

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk

Please check your Xcode installation

clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c src/MD2.c -o build/temp.macosx-10.6-intel-3.2/src/MD2.o

src/MD2.c:30:10: fatal error: 'string.h' file not found

#include <string.h>


1 error generated.

error: command 'clang' failed with exit status 1

Similar thing happens when attempting to install cryptacular.

As of version 2.4, Pycrypto says it supports python 3.

I'ved added a symlink to the xcode developer folder:

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer

but all that exists in that folder are MacOSX10.7.sdk MacOSX10.8.sdk (not MacOSX10.6.sdk as needed above).

Am I missing anything in my system? How can I tell it to use one of the other SDKs?


Got it to work by doing the following:

As in the comment above, made sure the Command Line Tools are installed, which also installs the system headers:

Start Xcode, open Xcode -> Preferences... and go to the Downloads tab. Under Components make sure the Command Line Tools are installed; this will also install system headers in system folders.

As instructed in this answer, create a symbolic link to the developer folder:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer

However, still go the error message:

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk

This relates to an issue that Python 3.2 assumes you are using Mac OSX 10.6

I fixed, this by faking the OSX 10.6 environment by creating a symbolic link from it to the OSX 10.8 environment:

sudo ln -s /Developer/SDKs/MacOSX10.8.sdk MacOSX10.6.sdk

Package successfully installs now.