2011-10-21 68 views
3

運行後:在Mac上的easy_install LXML不工作

sudo easy_install lxml 

我得到以下錯誤:

src/lxml/lxml.etree.c:165527: fatal error: error writing to -: Broken pipe 

編譯終止。

這看起來像一個C編譯器問題。

gcc --version 

收率4.2.1。

我真的不知道該從這裏做什麼。簡而言之,我想在10.6 OSX上安裝lxml。

+0

我想試試'pip'或者其中一個Mac軟件包管理器。 – Blender

回答

1

我無法在我的獅子的virtualenv使用或者PIP或easy_install的安裝,直到我這樣做:

STATIC_DEPS=true ./easy_install lxml 

該訣竅。

+0

在安裝結束時,可能需要sudo以避免「錯誤:/Library/Python/2.6/site-packages/easy-install.pth:權限被拒絕」。 – ganicus

0

嘗試使用pip

[ 11:34 [email protected] ~ ]$ sudo easy_install pip 
Searching for pip 
Reading http://pypi.python.org/simple/pip/ 
Reading http://www.pip-installer.org 
Reading http://pip.openplans.org 
Best match: pip 1.0.2 
Downloading http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz#md5=47ec6ff3f6d962696fe08d4c8264ad49 
Processing pip-1.0.2.tar.gz 
Running pip-1.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-uVpOHL/pip-1.0.2/egg-dist-tmp-Qz2FYz 
warning: no files found matching '*.html' under directory 'docs' 
warning: no previously-included files matching '*.txt' found under directory 'docs/_build' 
no previously-included directories found matching 'docs/_build/_sources' 
Adding pip 1.0.2 to easy-install.pth file 
Installing pip script to /usr/local/bin 
Installing pip-2.7 script to /usr/local/bin 

Installed /Library/Python/2.7/site-packages/pip-1.0.2-py2.7.egg 
Processing dependencies for pip 
Finished processing dependencies for pip 


[ 11:34 [email protected] ~ ]$ sudo pip install lxml 
Downloading/unpacking lxml 
    Downloading lxml-2.3.1.tar.gz (3.1Mb): 3.1Mb downloaded 
    Running setup.py egg_info for package lxml 
    Building lxml version 2.3.1. 
    Building without Cython. 
    Using build configuration of libxslt 1.1.24 

    warning: no previously-included files found matching '*.py' 
Installing collected packages: lxml 
    Running setup.py install for lxml 
    Building lxml version 2.3.1. 
    Building without Cython. 
    Using build configuration of libxslt 1.1.24 
    building 'lxml.etree' extension 
    llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.7-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace 
    llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.7-intel-2.7/lxml/etree.so 
    building 'lxml.objectify' extension 
    llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.macosx-10.7-intel-2.7/src/lxml/lxml.objectify.o -w -flat_namespace 
^@ llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.7-intel-2.7/lxml/objectify.so 

Successfully installed lxml 
Cleaning up... 
+0

使用pip,我得到了與op相同的錯誤。 Snow Leopard,python 2.6.1,GCC 4.2.1。 – alexplanation

3
export ARCHFLAGS='-arch i386 -arch x86_64' 

試圖PIP或之前的easy_install運行導出命令,以root身份。

+0

我得到了同樣的錯誤。 – super

+1

如果您正在使用'sudo easy_install',則可能無法正確導出ARCHFLAGS。請參閱此處的答案以瞭解如何解決此問題:http://stackoverflow.com/questions/5944332/broken-pipe-error-when-using-pip-to-install-pycrypto-on-mac-os-x/5944375 #5944375 –

+0

我收到了同樣的錯誤。我仍在研究解決方法。感謝鏈接愛。 – super

0

如果你在OS X Lion中,你可以嘗試用一個備用的編譯器建設:

export MACOSX_DEPLOYMENT_TARGET=10.7 
export CC=clang 
+0

我不會推薦在OS X上爲Python使用'clang'。在使用'clang'時,至少有一個已知的構建失敗,該修復會在下一輪Python發行版中發佈。而且我們還沒有徹底測試過鏗鏘聲。如果你已經安裝了Xcode 4.2,首先嚐試'CC = gcc',它應該使用'llvm-gcc'編譯器。 –

+0

Martin von Loewis報告說,與Lion合作的海灣合作委員會運輸版本是越野車,這就是爲什麼CPython負責人(3.3)無法使用默認設置進行構建。 –

+0

這很複雜。 Lion最初隨Xcode 4.1一起提供,它有三種不同的C編譯器:普通gcc-4.2,帶有llvm後端的gcc-4.2和clang。隨着Lion的10.7.2更新,Apple還公開發布了Xcode 4.2的主要更新,它更新了後兩個編譯器並刪除了簡單的gcc-4.2。馬丁的問題顯然是用gcc-llvm編譯器的一個版本(假設你指的是這個線程http://comments.gmane.org/gmane.comp.python.devel/126880);它是通過使用普通的gcc-4.2解決的。 –