Installing lxml | From lxml import etree
lxmlisgenerallydistributedthroughPyPI[1].MostLinuxplatformscomewithsomeversionoflxmlreadilypackaged,usuallynamedpython-lxmlforthePython2.xversionandpython3-lxmlforPython3.x.Ifyoucanusethatversion,thequickestwaytoinstalllxmlistousethesystempackagemanager,e.g.apt-getonDebian/Ubuntu:sudoapt-getinstallpython3-lxmlForMacOS-X,amacport[2]oflxmlisavailable.Trysomethinglikesudoportinstallpy27-lxmlToinstallanewerversionortoinstalllxmlonothersystems,seebelow.YouneedPython2.7or3.4+.Unlessyouareusingasta...
lxml is generally distributed through PyPI[1].
Most Linux platforms come with some version of lxml readily packaged, usually named python-lxml for the Python 2.x version and python3-lxml for Python 3.x. If you can use that version, the quickest way to install lxml is to use the system package manager, e.g. apt-get on Debian/Ubuntu:
sudo apt-get install python3-lxmlFor MacOS-X, a macport[2] of lxml is available. Try something like
sudo port install py27-lxmlTo install a newer version or to install lxml on other systems, see below.
You need Python 2.7 or 3.4+.
Unless you are using a static binary distribution (e.g. from a Windows binary installer), lxml requires libxml2 and libxslt to be installed, in particular:
libxml2[3] version 2.9.2 or later. libxslt version 1.1.27 or later.We recommend libxslt 1.1.28 or later. [4]Newer versions generally contain fewer bugs and are therefore recommended. XML Schema support is also still ...