Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find python lxml version

Tags:

python

lxml

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

like image 923
Niklas9 Avatar asked Dec 16 '13 12:12

Niklas9


People also ask

How do I get lxml version?

In case you want to use the current in-development version of lxml, you can get it from the github repository at https://github.com/lxml/lxml . Note that this requires Cython to build the sources, see the build instructions on the project home page.

How do I get lxml in Python?

Note: If you wish to install any particular version of lxml, you can simply state it when you run the command in the command prompt or terminal like this, lxml==3. x.y . By now, you should have a copy of the lxml library installed on your local machine.

Is lxml included in Python?

lxml has been downloaded from the Python Package Index millions of times and is also available directly in many package distributions, e.g. for Linux or macOS.

What is Python lxml?

Python lxml is the most feature-rich and easy-to-use library for processing XML and HTML data. Python scripts are written to perform many tasks like Web scraping and parsing XML. In this lesson, we will study about python lxml library and how we can use it to parse XML data and perform web scraping as well.


2 Answers

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.

like image 132
Simeon Visser Avatar answered Oct 04 '22 14:10

Simeon Visser


I assume you want to determine lxml's version programatically from Python. Since lxml does not provide this information via way of a typilca __version__ attribute on the top-level package you will have to resort to using setuptools' pkg_resources.require() function:

>>> from pkg_resources import require >>> match = require("lxml") >>> match [lxml 3.3.0beta1 (/home/prologic/lib/python2.7/site-packages)] >>> lxml = match[0] >>> lxml.version '3.3.0beta1' 
like image 25
James Mills Avatar answered Oct 04 '22 14:10

James Mills