How do you install lxml on OS X Leopard without using MacPorts or Fink?

后端 未结 15 2109
礼貌的吻别
礼貌的吻别 2020-11-30 20:23

I\'ve tried this and run in to problems a bunch of times in the past. Does anyone have a recipe for installing lxml on OS X without MacPorts or Fink that definitely works?<

相关标签:
15条回答
  • 2020-11-30 20:58

    Thanks to @jessenoller on Twitter I have an answer that fits my needs - you can compile lxml with static dependencies, hence avoiding messing with the libxml2 that ships with OS X. Here's what worked for me:

    cd /tmp
    curl -O http://lxml.de/files/lxml-3.6.0.tgz
    tar -xzvf lxml-3.6.0.tgz 
    cd lxml-3.6.0
    python setup.py build --static-deps --libxml2-version=2.7.3  --libxslt-version=1.1.24 
    sudo python setup.py install
    
    0 讨论(0)
  • 2020-11-30 20:58

    This worked for me (10.6.8):

    sudo env ARCHFLAGS="-arch i386 -arch x86_64" easy_install lxml
    
    0 讨论(0)
  • 2020-11-30 21:02

    I had this working fine with Snow Lepoard but after I upgraded to Lion I had to symlink gcc-4.2 to gcc. Running sudo env ARCHFLAGS="-arch i386 -arch x86_64" easy_install lxml was looking for gcc-4.2 instead of gcc.

    0 讨论(0)
  • 2020-11-30 21:06

    I've had excellent luck with Homebrew to install the libxml2 dependency:

    brew install libxml2
    

    Homebrew doesn't seem to have libxslt available, but I've not yet had a need for XSLT. YMMV.

    Once you have the dependency(s), then the usual methods work just fine:

    pip install lxml
    

    or

    easy_install lxml
    
    0 讨论(0)
  • 2020-11-30 21:08

    This is quite up to date - march 2009: http://lsimons.wordpress.com/2008/08/31/how-to-install-lxml-python-module-on-mac-os-105-leopard/

    0 讨论(0)
  • 2020-11-30 21:09

    using homebrew (0.9.5) on el capitan (10.11.1) the following worked for me:

    brew install libxml2
    LD_FLAGS=-L/usr/local/opt/libxml2/lib CPPFLAGS=-I/usr/local/opt/libxml2/include/libxml2 pip install lxml
    
    0 讨论(0)
提交回复
热议问题