Abstract lxml is a Python parsing library that supports HTML and XML parsing, support XPath analytical methods, and analytical efficiency is very high. In this section, we look at the installation lxml, mainly from Windows, Linux and Mac platforms to introduce three.
1. Links
-
Official Website: http://lxml.de
-
GitHub:https://github.com/lxml/lxml
2. Windows installation under
In Windows, you can first try to use pip to install, this time directly execute the following command:
pip3 install lxml
If there is no error, then it proves that the installation was successful.
If an error occurs, for example, suggested that the lack of information libxml2 library, etc., can be used wheel mounted.
Recommend directly to here (link to: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml ) corresponding wheel download files, find lxml version locally installed version of Python and corresponding systems, such as Windows 64-bit , Python 3.6, choose lxml-3.8.0-cp36-cp36m- win_amd64.whl, it is downloaded to the local.
Pip then be installed using the following command:
pip3 install lxml‑3.8.0‑cp36‑cp36m‑win_amd64.whl
So that we can successfully install the lxml.
3. Linux installation of
In the Linux platform installation is not a problem, first try to pip can also be installed with the following command:
pip3 install lxml
If errors are reported, try the following solutions.
CentOS、Red Hat
For such systems, error mainly because of the lack of necessary libraries.
Run the following command to install the required libraries to:
sudo yum groupinstall -y development tools
sudo yum install -y epel-release libxslt-devel libxml2-devel openssl-devel
Mainly libxslt-devel and libxml2-devel both libraries, lxml depend on them. After installing, try again to pip install.
Ubuntu、Debian和Deepin
In these systems, the reason being given is also likely to be a lack of the necessary libraries, execute the following command to install:
sudo apt-get install -y python3-dev build-essential libssl-dev libffi-dev libxml2 libxml2-dev libxslt1-dev
zlib1g-dev
After installing, try again to pip install.
4. Mac installed under
In the Mac platform, still you may first attempt to pip install command as follows:
pip3 install lxml
If an error occurs, you can execute the following command to install the necessary libraries:
xcode-select --install
After re-try pip install, there is no problem.
lxml is a very important library, behind Beautiful Soup, Scrapy frameworks need to use this library, so make sure the installation was successful.
5. Verify Installation
After the installation is complete, you can test the Python command line:
$ python3
>>> import lxml
If no error is reported, then it proves that libraries have been installed.
Source: Huawei cloud community Author: Cui Shu Jing Qing only seek