lxml xpath无法导入名称etree

时间:2015-11-30 19:30:55

标签: python lxml

在此lxml xpath教程之后使用Ubuntu 14.04 https://www.youtube.com/watch?v=PgWfF-Ut0zM

更新了下载pip的lxml上游版本 https://stackoverflow.com/a/33089634

sudo apt-get install python-pip
pip install -U lxml
python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> page = open('/root/page1.html').read()
>>> from lxml import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name etree

1 个答案:

答案 0 :(得分:3)

安装另一个版本的lxml解决了我的问题:

pip install lxml==3.6.0