Feedparser停止工作

时间:2011-02-08 14:24:07

标签: python feedparser

昨天我安装了feedparser(在OSX 10.5上)并且运行正常,但现在它停止了工作。

这是脚本(从feedparser文档中复制)

import feedparser
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
d['feed']['title']
u'Sample Feed'

它告诉我:

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    import feedparser
  File "example.py", line 2, in <module>
    d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
AttributeError: 'module' object has no attribute 'parse'

但是使用feedparser的实际脚本也停止了工作,同样的错误。

2 个答案:

答案 0 :(得分:8)

关键是当有一个名为feedparser.py的脚本时,python会将其视为要导入的模块,其优先级高于安装的模块。

答案 1 :(得分:0)

问题在于文件名。 Python在文件名和模块名之间混淆。