当我尝试使用"python feedparser“时,出现了一堆错误;而在安装过程中,没有出现任何问题。我做了一些这样的事情:
import feedparser
url = "http://blogsearch.google.dk/blogsearch_feeds?" + \
"q=visitdenmark&output=atom"
f = feedparser.parse(url)以及错误:
f = feedparser.parse(url)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 3798, in parse
feedparser.feed(data.decode('utf-8', 'replace'))
File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 1851, in feed
sgmllib.SGMLParser.feed(self, data)
File "/usr/lib/python2.6/sgmllib.py", line 104, in feed
self.goahead(0)
File "/usr/lib/python2.6/sgmllib.py", line 143, in goahead
k = self.parse_endtag(i)
File "/usr/lib/python2.6/sgmllib.py", line 320, in parse_endtag
self.finish_endtag(tag)
File "/usr/lib/python2.6/sgmllib.py", line 360, in finish_endtag
self.unknown_endtag(tag)
File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 659, in unknown_endtag
self.pop(prefix + suffix)
File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 868, in pop
mfresults = _parseMicroformats(output, self.baseuri, self.encoding)
File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 2412, in _parseMicroformats
p = _MicroformatsParser(htmlSource, baseURI, encoding)
File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 2016, in __init__
self.document = BeautifulSoup.BeautifulSoup(data)
AttributeError: 'module' object has no attribute 'BeautifulSoup'听到你的消息,
发布于 2011-02-11 01:06:43
AttributeError: 'module' object has no attribute 'BeautifulSoup'看起来你需要安装BeautifulSoup:
sudo apt-get install python-beautifulsoupPS。您已经在/usr/local中安装了feedparse的一个版本。还有一个用于feedparser的Ubuntu包:python-feedparser。它可能不是新的,但安装它会为您吸引所有的依赖项。
发布于 2011-02-24 07:18:25
你好!我在feedparser 5.0.1中看不到这一点;我的猜测是BeautifulSoup的安装方式很奇怪,或者您正在运行的feedparser代码已经以某种方式进行了修改。特别是,如果没有安装BeautifulSoup,微格式解析代码永远不应该运行,因此要达到这一点,然后发现模块中没有BeautifulSoup类,请使用is...weird。
如上所述,当您运行Python解释器并简单地输入
import BeautifulSoup
print BeautifulSoup.__file__
dir(BeautifulSoup)
BeautifulSoup.BeautifulSoup发布于 2015-12-11 16:54:18
我将分享我是如何修复这个错误的:我在Eclipse上使用Pydev作为IDE,而我所犯的错误是在安装Pydev时犯的。我为解释器选择了自动配置。这导致包含Python2.7作为解释器,从而导致错误。
https://stackoverflow.com/questions/4960166
复制相似问题