簡體   English   中英

pip在Mac OS X Mavericks(10.9)上引發stdio.h找不到錯誤

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

在這一點上,我嘗試了無數解決方案,但似乎沒有任何效果。 我正在嘗試安裝mysql-python,但這在numpy和其他需要gcc的軟件包中也會發生:

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

要指出:

我已經安裝了命令行工具

從/ usr / bin / gcc添加符號鏈接到/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

創建了一個虛擬c文件,成功編譯並運行了它,所以gcc本身就很好

$ 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

而且很好

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

到底是怎么回事?!

編輯 -忘記包含python版本

$ 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

編輯 -令人興奮的發展。 設置這些變量會帶來一些進步:

$ 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"

但是它再次失敗

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

我懷疑這是與命令工具有關的類似錯誤。 另外,為什么使用“ /Developer/SDKs/MacOSX10.6.sdk”? (請問一下noob的問題,我正在嘗試從vim / unix遷移到pycharm / mac,到目前為止進展不順利:()

從Mojave xcode-select --install開始,您還應該安裝可以在/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg找到的軟件包。 資料來源: https : //forums.developer.apple.com/thread/104296

正如上面提到的@wegry-

brew install python

與確認

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

只是使這個完全消失了。 用pip成功安裝了numpy和mysql-python!

這對我有用

xcode-select --install

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM