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

查看:123
本文介绍了Mac OS-X Mountain Lion上的GCC-4.2错误,无法使用pip / virtualenv安装某些软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一个非常恼人的错误,我不知道该如何处理。这似乎是相当普遍的,我已经尝试了几乎所有我能找到的解决方案,但都无济于事。

我正在尝试使用pip安装库。 gevent,psycopg2和greenlet遇到了这个问题。这个问题似乎是我的电脑无法找到一个特定的C编译器,它应该提供XCode 4:gcc-4.2。这里有一个例子(尽管也是在virtualenv中进行的尝试)。

 上次登录:Sun Jul 29 23:35:54 on ttys000 
******* s- MacBook-Pro:〜****** $ pip install gevent
下载/解压gevent
下载gevent-0.13.7.ta​​r.gz(288Kb):288Kb已下载
运行设置。 py egg_info for package gevent

下载/解压greenlet(来自gevent)
正在下载greenlet-0.4.0.zip(72Kb):72Kb已下载
运行setup.py egg_info for package greenlet

安装收集的软件包:gevent,greenlet
运行setup.py安装gevent
构建'gevent.core'扩展
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
从/Library/Frameworks/Python.framework/Versions/包含的文件中2.7 / include / python2.7 / unicodeobject.h:4,
来自/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,来自gevent / core.c的
:4:
/ Developer / SDKs / MacOSX10。 6.sdk / usr / include / stdarg.h:4:25:error:stdarg.h:没有这样的文件或目录
包含在gevent / core.c中的文件:225:
gevent / libevent .h:9:19错误:event.h:没有这样的文件或目录
gevent / libevent.h:38:20:错误:evhttp.h:没有这样的文件或目录
gevent / libevent .h:39:19错误:evdns.h:没有这样的文件或目录
gevent / core.c:361:error:field'ev'有不完整的类型
gevent / core.c:741 :警告:函数声明中的参数名称(不带类型)

....更多类似这样的内容,但现在我将跳过它....

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

正在运行build_ext

建立'gevent.core'扩展

创建构建/临时.macosx-10.6-intel-2.7

创建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

从/Library/Frameworks/Python.framework/Versions/包含的文件中2.7 / include / python2.7 / unicodeobject.h:4,
$ b $ from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,$ b gevent / core.c中的
$ b:4:

/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25:error:stdarg。 h:没有这样的文件或目录

从gevent / core.c包含的文件中:225:

gevent / libevent.h:9:19:error: event.h:没有这样的文件或目录

gevent / libevent.h:38:20:错误:evhttp.h:没有这样的文件或目录

gevent / libevent。 h:39:19:error:evdns.h:没有这样的文件或目录

....更像这样以及....

gevent / core。 c:15559:warning:赋值使得整型指针没有转换

gevent / core.c:顶层:

gevent / core.c:21272:error: ''''之前'val'

lipo:找不到以下架构类型:/var/folders/xc/f2mg5kn96kqdr3tj19pgyhs00000gn/T//cckLxkJ2.out

错误:命令'gcc-4.2'失败,退出状态1

命令/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().export('\r\\\
',' \ n'),__file__,'exec'))install --single-version -external-managed --record / var / folders / xc / f2mg5kn96kqdr3tj19pgyhs00000gn / T / pip-yA5oWR-record / install-record.txt失败,错误代码1位于/ Users / ****** / build / gevent
存储完整登录/ Users / *** *** / .pip / pip.log
*********** s-MacBook-Pro:〜****** $

您可能会问的问题:

1)您是否尝试过使用virtualenv?



是的。我尝试将以前存在的gcc(它存在于/ usr / bin /目录中)象符号链接: 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:无输入文件

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
输入help,copyright,credits或license以获取更多信息。

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



我也尝试安装这个: https://github.com / kennethreitz / osx-gcc-installer 。我不知道还有什么可以尝试的。在这个unix-y编码/安装方面,我是一个新手,所以如果有什么我做得非常糟糕,请指出。



谢谢!

解决方案

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


$ b


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


在Mac OSx Mountain Lion 10.8我使用命令行工具安装了xCode 4.3。我做了更新到xCode 4.4,它仍然没有工作。即使安装了Xcode,显然也不会自动下载新的命令行工具。正如jiaaro的帖子所述,你必须明确地下载命令行工具。



当前版本的gcc在下面,并且成功地为我sudo pip install virtualenv包无需sym链接。




i686-apple-darwin11 -llvm-gcc-4.2



I'm seeing a very annoying bug that I don't really know how to deal with. It seems to be pretty common, and I've tried nearly every solution that I could find to no avail.

I'm trying to install libraries using pip. This problem was encountered with gevent, with psycopg2, and with greenlet. The issue seems to be that my computer can't find a particular C compiler that should come up with XCode 4: gcc-4.2. Here's an example (though attempts were made in a virtualenv as well).

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:~ ******$ 

Things you might ask:

1) Did you try using a virtualenv?

Yes. And I attempted to symlink a preexisting gcc (which is present in the /usr/bin/ directory) like so:

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

None of which worked.

2) Did you try reinstalling XCode?

Yes.

3) Did you install the XCode Command Line Tools?

Yes.

4) Are you sure you have gcc?

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

5) Python installation?

************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.

Any ideas on what might be wrong and how to fix it?

I also tried installing this: https://github.com/kennethreitz/osx-gcc-installer . I have no idea what else to try. I'm a bit of a new kid on the block when it comes to this unix-y coding / installation things, so if there is something I'm doing very badly please point it out.

Thanks!

解决方案

Same problem with pycrypto install failing to compile in a virtualenv. Found the solution in this thread by poster jiaaro: https://gist.github.com/3179227#gistcomment-379913

You need to install Xcode 4.4 (from the app store) and then, within xcode open Xcode > Preferences (or press Cmd + ,) then open the downloads tab and install the Command Line Tools.

On Mac OSx Mountain Lion 10.8 I had xCode 4.3 installed WITH the command line tools. I did the update to xCode 4.4 and it still didn't work. Xcode does not automatically download the new command line tools apparently even if you had them installed. As the post from jiaaro states, you have to explicitly download the command line tools again.

Current version of gcc is below and does successfully sudo pip install packages in virtualenv for me with no need to sym link.

gcc

i686-apple-darwin11-llvm-gcc-4.2

这篇关于Mac OS-X Mountain Lion上的GCC-4.2错误,无法使用pip / virtualenv安装某些软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆