3

After running:

sudo easy_install lxml

I get the following error:

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

compilation terminated.

This looks like a c-compiler problem.

 gcc --version 

yields 4.2.1.

I don't really know what to do from here. Simply put, I want to install lxml on 10.6 OSX.

super
  • 181
  • 2
  • 12

5 Answers5

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

Run the export command, as root, before trying pip or easy_install.

Griffin
  • 644
  • 6
  • 18
  • 1
    If you are using `sudo easy_install` you may be not be properly exporting `ARCHFLAGS`. See the answer here for how to work around that: http://stackoverflow.com/questions/5944332/broken-pipe-error-when-using-pip-to-install-pycrypto-on-mac-os-x/5944375#5944375 – Ned Deily Oct 21 '11 at 19:31
  • I received the same error. I am still working on a workaround. Thanks for the link love. – super Oct 23 '11 at 21:03
1

I was unable to install using either pip or easy_install in my virtualenv in Lion until I did this:

STATIC_DEPS=true ./easy_install lxml

That did the trick.

somewhatoff
  • 971
  • 1
  • 11
  • 25
  • A sudo may be needed to avoid a "error: /Library/Python/2.6/site-packages/easy-install.pth: Permission denied" at the end of the install. – ganicus Jul 02 '14 at 19:41
0

Try using 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...
chown
  • 51,908
  • 16
  • 134
  • 170
0

If you're on OS X Lion, you can try building with an alternate compiler:

export MACOSX_DEPLOYMENT_TARGET=10.7
export CC=clang
Raymond Hettinger
  • 216,523
  • 63
  • 388
  • 485
  • I wouldn't recommend using `clang` for Python on OS X - yet. There is at least one known build failure when using `clang` which has a fix to be released in the next round of Python releases. And we haven't thoroughly tested clang yet. If you have installed Xcode 4.2, try `CC=gcc` first, which should use the `llvm-gcc` compiler. – Ned Deily Oct 21 '11 at 19:34
  • Martin von Loewis reported that the version of GCC shipping with Lion is buggy and that is why the CPython head (3.3) fails to build with the defaults. – Raymond Hettinger Oct 21 '11 at 20:55
  • It's complicated. Lion initially shipped with Xcode 4.1 which has three different C compilers: plain gcc-4.2, gcc-4.2 with an llvm backend, and clang. With the 10.7.2 update to Lion, Apple also publicly released a major update to Xcode, 4.2, which updated the later two compilers and removed the plain gcc-4.2. Martin's problem was apparently with a version of gcc-llvm compiler (assuming you're referring to this thread http://comments.gmane.org/gmane.comp.python.devel/126880); it was resolved by using the plain gcc-4.2. – Ned Deily Oct 21 '11 at 21:13
  • To use clang successfully, you need at least the patches for http://bugs.python.org/issue11149 but there may be more issues. Other projects, like MacPorts, have been working though a bunch of issues with their ports using clang on 10.7. And now with Xcode 4.2, the plain gcc-4.2 has been removed. In any case, the OP says he's using 10.6 where there are both Xcode 3 and Xcode 4 options available. Ugh. – Ned Deily Oct 21 '11 at 21:14
0

I just installed the gcc compiler and everything worked well.

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

super
  • 181
  • 2
  • 12