python feedparser安装错误
当我尝试使用“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'
收到你的来信,
There is bunch of error when I try to use "python feedparser"; while during installation there is no complain.
I do some thing like this:
import feedparser
url = "http://blogsearch.google.dk/blogsearch_feeds?" + \
"q=visitdenmark&output=atom"
f = feedparser.parse(url)
and the error :
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'
Hearing from you,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来你需要安装BeautifulSoup:
PS。您已在 /usr/local 中安装了 feedparse 的一个版本。
还有一个用于 feedparser 的 Ubuntu 软件包:
python-feedparser
。它可能不是新的,但安装它会为您引入所有依赖项。It looks like you need to install BeautifulSoup:
PS. You've installed a version of feedparse in /usr/local.
There is also an Ubuntu package for feedparser:
python-feedparser
. It may not be as new, but installing it would have drawn in all dependencies for you.你好!我在 feedparser 5.0.1 中没有看到这个;我的猜测是 BeautifulSoup 安装得很奇怪,或者您正在运行的 feedparser 代码已被以某种方式修改。特别是,如果未安装 BeautifulSoup,微格式解析代码永远不会运行,因此达到这一点然后发现模块中没有 BeautifulSoup 类是......奇怪的。
如上所述,当您运行 Python 解释器并简单地键入时,您会得到什么
Howdy! I'm not seeing this in feedparser 5.0.1; my guess is that BeautifulSoup is installed strangely, or that the feedparser code you're running has been modified in some way. In particular, the microformat parsing code should never run if BeautifulSoup isn't installed, so to reach that point and then find that the module doesn't have a BeautifulSoup class in it is...weird.
As noted above, what do you get when you run the Python interpreter and simply type
我将分享我如何修复此错误:
我在 Eclipse 上使用 Pydev 作为 IDE,我犯的错误是在安装 Pydev 的过程中。我为解释器选择了自动配置。这导致包含 Python 2.7 作为解释器,从而导致错误。
I will share how I fixed this error:
I was using Pydev on Eclipse as IDE and the mistake I made was during the installation of Pydev. I selected the Auto Config for interpreter. This resulted into the inclusion of Python 2.7 as the interpreter and thus was resulting in the error.