您的位置:首页 > 编程语言 > Python开发

python3 安装lxml 大坑

2016-08-26 16:28 155 查看
用bs4 解析xml的时候发现有lxml包的依赖,安装lxml一直不成功:

这个地址http://lxml.de/installation.html ,官方安装说明,

You need Python 2.6 or later.

libxml2 version
2.7.0 or later.

libxslt version
1.1.23 or later.

在linux下安装的过程跳过,可以参考文档说明

在windows下,建议是直接使用二进制文件安装。

unofficial
Windows binaries:http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

随便下了一个,在pip install *whl 失败!提示说平台不支持,又蒙了

[plain] view
plain copy

is not a supported wheel on this platform  

原来,lxml-3.4.4-cp34-none-win32.whl ,cp34对应不同的Python版本支持,需要查看自己的Python版本支持情况:

[python] view
plain copy

import pip; print(pip.pep425tags.get_supported())  

[python] view
plain copy

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In  

Type "help", "copyright", "credits" or "license" for more information.  

>>> import pip; print(pip.pep425tags.get_supported())  

[('cp34', 'none', 'win32'), ('py3', 'none', 'win32'), ('cp34', 'none', 'any'), (  

e', 'any'), ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', '  

3', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', '  

')]  

显然,用cp34-none-win32才可以

[python] view
plain copy

pip install lxml-3.4.4-cp34-none-win32.whl  

windows环境下成功安装lxml。

[python] view
plain copy

Processing d:\order\lxml-3.4.4-cp34-none-win32.whl  

Installing collected packages: lxml  

Successfully installed lxml-3.4.4  

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: