Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip raises stdio.h not found error on Mac OS X Mavericks (10.9)

I have tried countless solutions at this point and nothing seems to work. I'm trying to install mysql-python, but this happens with numpy and other packages requiring gcc as well:

building '_mysql' extension

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64

In file included from _mysql.c:29:

/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:10: fatal error: 'stdio.h' file not found

#include <stdio.h>

         ^

1 error generated.

error: command 'gcc-4.2' failed with exit status 1

To point:

I have installed command line tools

Added symlink from /usr/bin/gcc to /usr/bin/gcc-4.2

gcc-4.2 --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

Created a dummy c file, successfully compiled, and ran it, so gcc itself is fine

$ cat a.c
#include <stdio.h>

main()
{
    printf("hello\n");
}

$ gcc-4.2 a.c
a.c:3:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main()
^~~~
1 warning generated.

$ ./a.out
hello

And for good measure,

$ xcode-select -p
/Library/Developer/CommandLineTools

What is going on?!

EDIT - Forgot to include python version

$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

EDIT - Exciting development. Setting these variables makes some progress:

$ export CFLAGS="-arch i386 -arch x86_64"
$ export FFLAGS="-m32 -m64"
$ export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
$ export CC=gcc-4.2
$ export CXX="g++ -arch i386 -arch x86_64"

However it fails again at

gcc-4.2 -bundle -undefined dynamic_lookup -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -Wall -undefined dynamic_lookup -bundle build/temp.macosx-10.6-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -o build/lib.macosx-10.6-intel-2.7/_mysql.so -arch x86_64

ld: library not found for -lSystem

clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command 'gcc-4.2' failed with exit status 1

I suspect it's a similar error having to do with command tools. Also, why is it using "/Developer/SDKs/MacOSX10.6.sdk" ? (excuse the noob questions, I'm trying to migrate from vim/unix to pycharm/mac and it's not going very well so far :( )

like image 774
beans Avatar asked May 09 '14 20:05

beans


2 Answers

Starting from Mojave xcode-select --install is not enough, you should also install the package that can be found at /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg. Source: https://forums.developer.apple.com/thread/104296

like image 141
MrTJ Avatar answered Oct 06 '22 00:10

MrTJ


As @wegry mentioned above--

brew install python

confirming with

$ which python
/usr/local/homebrew/bin/python

just made this entirely go away. Successfully installed numpy and mysql-python with pip!

like image 40
beans Avatar answered Oct 06 '22 00:10

beans