小编Mar*_*333的帖子

如何重新安装lxml?

我在mac 10.7.5上使用python 2,7.5,beautifulsoup 4.2.1.我将使用lxml库解析xml页面,如beautifulsoup教程中所述.但是,当我运行我的代码时,它会显示出来

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
lxml,xml. Do you need to install a parser library?
Run Code Online (Sandbox Code Playgroud)

我确信我已经通过所有方法安装了lxml:easy_install,pip,port等.我试着在我的代码中添加一行,看看是否安装了lxml:

import lxml
Run Code Online (Sandbox Code Playgroud)

然后python可以成功浏览此代码并再次显示上一条错误消息,发生在同一行.

所以我很确定已经安装了lxml,但没有正确安装.所以我决定卸载lxml,然后使用'正确'方法重新安装.但是当我输入时

easy_install -m  lxml
Run Code Online (Sandbox Code Playgroud)

表明:

Searching for lxml
Best match: lxml 3.2.1
Processing lxml-3.2.1-py2.7-macosx-10.6-intel.egg

Using /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-
3.2.1-py2.7-macosx-10.6-intel.egg

Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, …
Run Code Online (Sandbox Code Playgroud)

python lxml beautifulsoup easy-install

16
推荐指数
3
解决办法
3万
查看次数

标签 统计

beautifulsoup ×1

easy-install ×1

lxml ×1

python ×1