繁体   English   中英

Mac OS-X Mountain Lion上出现GCC-4.2错误,无法使用pip / virtualenv安装某些软件包

[英]GCC-4.2 error on Mac OS-X Mountain Lion, unable to install some packages with pip / virtualenv

我看到一个非常烦人的错误,我真的不知道如何处理。 这似乎很常见,我几乎尝试了所有我找不到的解决方案。

我正在尝试使用pip安装库。 gevent,psycopg2和greenlet遇到了这个问题。 问题似乎是我的计算机找不到应该提出XCode 4的特定C编译器:gcc-4.2。 这是一个例子(虽然尝试也是在virtualenv中)。

Last login: Sun Jul 29 23:35:54 on ttys000
*******s-MacBook-Pro:~ ******$ pip install gevent
Downloading/unpacking gevent
  Downloading gevent-0.13.7.tar.gz (288Kb): 288Kb downloaded
  Running setup.py egg_info for package gevent

Downloading/unpacking greenlet (from gevent)
  Downloading greenlet-0.4.0.zip (72Kb): 72Kb downloaded
  Running setup.py egg_info for package greenlet

Installing collected packages: gevent, greenlet
  Running setup.py install for gevent
    building 'gevent.core' extension
    gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c gevent/core.c -o build/temp.macosx-10.6-intel-2.7/gevent/core.o
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
                 from gevent/core.c:4:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from gevent/core.c:225:
gevent/libevent.h:9:19: error: event.h: No such file or directory
gevent/libevent.h:38:20: error: evhttp.h: No such file or directory
gevent/libevent.h:39:19: error: evdns.h: No such file or directory
gevent/core.c:361: error: field ‘ev’ has incomplete type
gevent/core.c:741: warning: parameter names (without types) in function declaration

....more like this but i'll skip it for now....

copying gevent/wsgi.py -> build/lib.macosx-10.6-intel-2.7/gevent

running build_ext

building 'gevent.core' extension

creating build/temp.macosx-10.6-intel-2.7

creating build/temp.macosx-10.6-intel-2.7/gevent

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c    gevent/core.c -o build/temp.macosx-10.6-intel-2.7/gevent/core.o

In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,

             from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,

             from gevent/core.c:4:

/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory

In file included from gevent/core.c:225:

gevent/libevent.h:9:19: error: event.h: No such file or directory

gevent/libevent.h:38:20: error: evhttp.h: No such file or directory

gevent/libevent.h:39:19: error: evdns.h: No such file or directory

....more like this as well....

gevent/core.c:15559: warning: assignment makes pointer from integer without a cast

gevent/core.c: At top level:

gevent/core.c:21272: error: expected ‘)’ before ‘val’

lipo: can't figure out the architecture type of:    /var/folders/xc/f2mg5kn96kqdr3tj19pgyhs00000gn/T//cckLxkJ2.out

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

Command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c        "import setuptools;__file__='/Users/******/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record   /var/folders/xc/f2mg5kn96kqdr3tj19pgyhs00000gn/T/pip-yA5oWR-record/install-record.txt failed with error code 1 in /Users/******/build/gevent
Storing complete log in /Users/******/.pip/pip.log
***********s-MacBook-Pro:~ ******$ 

你可能要问的事情:

1)你尝试过使用virtualenv吗?

是。 我尝试将预先存在的gcc(存在于/ usr / bin /目录中)符号链接,如下所示:

ln -s /usr/bin/gcc gcc-4.2
ln -s /usr/bin/gcc-4.2 gcc-4.2
ln -s /usr/bin/gcc gcc

这些都没有奏效。

2)您是否尝试重新安装XCode?

是。

3)您是否安装了XCode命令行工具?

是。

4)你确定你有gcc吗?

**********s-MacBook-Pro:~ sanjay$ gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files

5)Python安装?

************s-MacBook-Pro:~ ******$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

关于什么可能是错的以及如何解决它的任何想法?

我也试过安装: https//github.com/kennethreitz/osx-gcc-installer 我不知道还有什么可以尝试的。 当谈到这个unix-y编码/安装的东西时,我是一个新生儿,所以如果有什么我做得非常糟糕请指出来。

谢谢!

与pycrypto安装相同的问题无法在virtualenv中编译。 通过海报jiaaro找到解决方案: https ://gist.github.com/3179227#gistcomment-379913

您需要安装Xcode 4.4(从应用程序商店),然后在xcode中打开Xcode> Preferences(或按Cmd +),然后打开下载选项卡并安装命令行工具。

在Mac OSx Mountain Lion 10.8上,我使用命令行工具安装了xCode 4.3。 我对xCode 4.4进行了更新,但仍然无法正常工作。 即使安装了Xcode,Xcode也不会自动下载新的命令行工具。 正如jiaaro所述的帖子,您必须再次明确下载命令行工具。

gcc的当前版本如下所示,并且在我的virtualenv中成功完成了sudo pip安装包,而不需要sym链接。

GCC

i686的 - 苹果darwin11-LLVM-GCC-4.2

设置这个环境变量对我来说,不需要乱用Xcode或它的下载。

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

不确定这是否有帮助,但也许值得一试:

https://gist.github.com/3179227

所以我已经从自己解决了这个问题,但我现在生活在狂野的西部,我现在解决问题,并担心在事情发生时采取正确的方法。 我刚刚创建了一个符号链接,以便stdargs.h位于合理的位置,在请求时可以看到它。

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdarg.h

您可能必须将“MacOSX10.8.sdk”更改为您当前使用的那个。 有希望

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM