Today want to try Beautifulsoup4, the installation is very smooth, and then ready to install lxml as a parser, did not expect to install the PIP directly to me a full page error.
Resolution process
Look at the error message, which has the following paragraph:
*********************************************************************************Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?*********************************************************************************
So I manually installed the library, and found that it has actually been installed, then why do you prompt this problem? So I went back to see the output hints, found the two lines:
ERROR: b‘/bin/sh: 1: xslt-config: not found\n‘** make sure the development packages of libxml2 and libxslt are installed **
The original to install the dev package ah. Input sudo apt-get install libxml2-dev libxslt1-dev , should it be done?
It turned out that I was happy too early, though no longer reported this mistake, but the installation of lxml failed. Helpless, can only continue to see error tips. An error message was found:
src/lxml/lxml.etree.c:82:20: fatal error: Python.h: 没有那个文件或目录
Check, this is python-dev a header file provided in, so need to install python-dev (I use Python3, so installed python3-dev ). Install with APT, and then use pip install lxml , did not think that still error can not install Orz. This time the mistake changed one:
/usr/bin/ld: cannot find -lz
StackOverflow on this issue to provide the method is installed zlib1g-dev , with Apt-get after installation, try to lxml again, finally compile the installation successfully.
Summarize
In fact, with one command, a few dev packs are needed to get it done.
sudo apt-get install python-dev python3-dev libxml2-dev libxslt1-dev zlib1g-dev
It was later discovered that someone on StackOverflow had asked the question.
Turn http://blog.csdn.net/lincifer/article/details/51296559
Python pip installation lxml failed (GO)