easy_install lxml在mac上无法正常工作

时间:2011-10-21 18:31:15

标签: python gcc 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。

5 个答案:

答案 0 :(得分:3)

export ARCHFLAGS='-arch i386 -arch x86_64'

在尝试pip或easy_install之前,以root身份运行export命令。

答案 1 :(得分:1)

我无法在Lion的virtualenv中使用pip或easy_install进行安装,直到我这样做:

STATIC_DEPS=true ./easy_install lxml

这就是诀窍。

答案 2 :(得分:0)

尝试使用pip

[ 11:34 Jonathan@MacBookPro ~ ]$ 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 Jonathan@MacBookPro ~ ]$ 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...

答案 3 :(得分:0)

如果您使用的是OS X Lion,则可以尝试使用备用编译器进行构建:

export MACOSX_DEPLOYMENT_TARGET=10.7
export CC=clang

答案 4 :(得分:0)

我刚刚安装了gcc编译器,一切运行良好。

https://github.com/kennethreitz/osx-gcc-installer

相关问题