Find python lxml version

Niklas9 picture Niklas9 · Dec 16, 2013 · Viewed 15.6k times · Source

How can I find the installed python-lxml version in a Linux system?

>>> import lxml
>>> lxml.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__version__'

>>> from pprint import pprint
>>> pprint(dir(lxml))
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 'get_include',
 'os']
>>>

Can't seem to find it

Answer

Simeon Visser picture Simeon Visser · Dec 16, 2013

You can get the version by looking at etree:

>>> from lxml import etree
>>> etree.LXML_VERSION
(3, 0, -198, 0)

Other versions of interest can be: etree.LIBXML_VERSION, etree.LIBXML_COMPILED_VERSION, etree.LIBXSLT_VERSION and etree.LIBXSLT_COMPILED_VERSION.