在Mac上使用easy_install安装lxml失败

3 投票
5 回答
2606 浏览
提问于 2025-04-17 04:46

在运行以下代码后:

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

试试用 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
export ARCHFLAGS='-arch i386 -arch x86_64'

在尝试使用pip或easy_install之前,先以管理员身份运行导出命令。

1

我在Lion系统的虚拟环境中,使用pip或easy_install都无法安装,直到我做了这个:

STATIC_DEPS=true ./easy_install lxml

这样就解决问题了。

撰写回答