This article briefly introduces how to install the LXML module using Python in windows and linux systems. It is very simple and practical, if you have any need, refer to lxml as the most abundant and easy-to-use library related to XML and HTML in Python. Lxml is not a Python package, but a Python-based binding between libxml2 and libxslt libraries. What makes it different is that it takes into account the speed and functional integrity of these libraries, as well as the simplicity of pure Python APIs. It is compatible with the well-known ElementTree API, but is superior to it! However, installing lxml is a little troublesome. Because of the dependency, if you install lxml directly, easy_install and pip cannot succeed, and a gcc error will be reported.
LXML is usually installed for crawlers.
pip install lxml
Solution to the following error:
lxml Unable to find vcvarsall.bat
1. Install wheel and run the following command:
pip install wheel
2. Download the corresponding. whl file here (open the URL and press ctrl + F to search for LXML, select the corresponding version, generally win32, rather than win_arm64, even if the computer is win64)
Http://www.lfd.uci.edu /~ Gohlke/pythonlibs/# lxml
3. Go to the folder where. whl is located-> shift + right-click-> open the command window here
4. Execute the command to complete the installation:
pip install lxml-3.6.0-cp35-cp35m-win32.whl
Additionally, the installation of LXML in Linux is attached.
The packages that lxml depends on are as follows:
Libxml2, libxml2-devel, libxlst, libxlst-devel, python-libxml2, python-libxslt
The installation steps are as follows:
Step 1: Install libxml2
$ sudo apt-get install libxml2 libxml2-dev
Step 2: Install libxslt
$ sudo apt-get install libxlst libxslt-dev
Step 3: Install python-libxml2 and python-libxslt
$ sudo apt-get install python-libxml2 python-libxslt
Step 4: Install lxml
$ sudo easy_install lxml