2011-10-21 69 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解决的。 –