python - pip 在 Mac OS X Mavericks (10.9) 上引发 stdio.h not found 错误

标签 python macos gcc numpy mysql-python

此时我已经尝试了无数解决方案,但似乎没有任何效果。我正在尝试安装 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 的符号链接(symbolic link)

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”? (请原谅菜鸟问题,我正在尝试从 vim/unix 迁移到 pycharm/mac,但目前进展不顺利 :( )

最佳答案

从 Mojave 开始 xcode-select --install 是不够的,您还应该安装可以在 /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14 中找到的包。包装。来源:https://forums.developer.apple.com/thread/104296

关于python - pip 在 Mac OS X Mavericks (10.9) 上引发 stdio.h not found 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23573629/

相关文章:

ios - macOS 和 iOS 目标是否应该共享相同的授权文件?

c++ - g++ 编译选项 -std=c++14 编译错误显示 Werror=c++11-compat

c - 如何在 Sublime Text 2 [MAC OS X] 上运行和编译 .c

python - Django NameError [应用程序名称] 未定义

Python PPTX table.cell 颜色

python - spacy : "No module named en" 导入错误

ruby - 使用 GeekTools 在 MacOS 桌面上显示需要 Mechanize 的 ruby​​ 脚本的输出?

ios - SecPKCS12Import when p12 requires an empty passphrase

c++ - 为什么 g++ 从带有转换运算符和不可访问的函数调用运算符的类型中初始化 std::function<> 失败?

python - 无法通过 Python/psycopg2 将数据插入 Postgresql 数据库