【Python爬虫】安装 pyQuery 遇到的坑 Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
windows 64位操作系统下,用 Python 抓取网页,并用 pyQuery 解析网页
pyQuery是jQuery在python中的实现,能够以jQuery的语法来操作解析HTML文档,十分方便。使用前需要安装,easy_install pyquery即可,或者Ubuntu下
详情参考:
http://blog.csdn.net/zhaoyl03/article/details/8631645
但是用pip命令安装pyquey的时候,报错了
pip install pyquery
提示需要先安装 lxml ,于是用如下命令安装 lxml
pip install lxml
报错
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
查资料,知乎上找到如下解决方案:https://www.zhihu.com/question/30047496 亲测有效。
1. 安装wheel,命令行运行: pip install wheel 2.在这里下载对应的.whl文件,注意别改文件名! http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml 3. 进入.whl所在的文件夹,执行命令即可完成安装 pip install 带后缀的完整文件名
从上面的地址下载到适合我电脑的whl文件:lxml-3.6.4-cp27-cp27m-win_amd64.whl
然后在安装 pyquery,成功搞定!
C:\Python27\Scripts>pip install lxml-3.6.4-cp27-cp27m-win_amd64.whl Processing c:\python27\scripts\lxml-3.6.4-cp27-cp27m-win_amd64.whl Installing collected packages: lxml Successfully installed lxml-3.6.4 C:\Python27\Scripts>pip install pyquery Collecting pyquery Using cached pyquery-1.2.17-py2.py3-none-any.whl Requirement already satisfied: lxml>=2.1 in c:\python27\lib\site-packages (from pyquery) Requirement already satisfied: cssselect>0.7.9 in c:\python27\lib\site-packages (from pyquery) Installing collected packages: pyquery Successfully installed pyquery-1.2.17