pip在Mac OS X Mavericks上引发stdio.h未找到错误(10.9)

 新梅乀_Esther 发布于 2023-01-15 19:11

我已经尝试了无数的解决方案,似乎没有任何工作.我正在尝试安装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 

         ^

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 

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,到目前为止它还不是很顺利:()

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有