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

后端 未结 15 2340
礼貌的吻别
礼貌的吻别 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:53

    A lot of pain went into this for an outdated 10.6.8 os x but here it goes for anyone running Snow Leopard!

    First you have to install a different version of libxml2 from homebrew and install --with-python. You can do this by typing in the following commands.

    brew update
    brew edit libxml2
    

    Then find the line that says "--without-python" and change to "--with-python".

    system "./configure", "--disable-dependency-tracking",
                          "--prefix=#{prefix}",
                          "--with-python"
    

    Now you can install libxml2.

    brew install libxml2
    

    Next check your new install of libxml2 in the default homebrew location. You want to find the libxml2 config.

    YOURS MAY BE DIFFERENT:

    "/usr/local/Cellar/libxml2/VERSION_/bin/xml2-config"

    Now use the following command to install lxml with pip using the newly installed libxml2 config and not the Mac OS X version.

    ARCHFLAGS="-arch i386 -arch x86_64" pip install lxml --install-option="--with-xml2-config=/usr/local/Cellar/libxml2/2.9.1/bin/xml2-config"
    

    Worked for me on my 10.6.8 Python 2.6. Thanks.

    Credit goes to this page for showing me pip --install-option ...

    http://natanyellin.com/page/4/

提交回复
热议问题