簡體   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