ImportError:运行Yahoo BOSS时找不到etree.ElementTree模块

-3 投票
2 回答
3122 浏览
提问于 2025-04-15 15:53

我安装了Yahoo BOSS(这是一个Python的安装包,让你可以使用他们的搜索功能)。我按照说明一步步来,没错。但是,当我运行示例来确认它能正常工作时,却出现了这个:

$ python ex3.py
Traceback (most recent call last):
  File "ex3.py", line 16, in ?
    from yos.yql import db
  File "/usr/lib/python2.4/site-packages/yos/yql/db.py", line 44, in ?
    from yos.crawl import rest
  File "/usr/lib/python2.4/site-packages/yos/crawl/rest.py", line 13, in ?
    import xml2dict
  File "/usr/lib/python2.4/site-packages/yos/crawl/xml2dict.py", line 6, in ?
    import xml.etree.ElementTree as ET
ImportError: No module named etree.ElementTree

有没有什么办法可以解决这个问题?我完全按照文档上的步骤操作,而且是在一个全新的环境下安装的。

有人建议使用Python 2.5,但现在大家都在用Python 2.4。我该怎么做才能让这个Yahoo BOSS正常工作呢?

Python 2.4.3 (#1, Sep  3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2

2 个回答

0

在谷歌搜索中可以发现,你需要安装一个叫做 effbot elementtree 的Python模块。

3

使用Python 2.5或更高版本:xml.etree.ElementTree是在2.5版本中新增的。

http://docs.python.org/library/xml.etree.elementtree.html

撰写回答