python feedparser安装错误

发布于 2024-10-17 00:12:03 字数 1706 浏览 4 评论 0原文

当我尝试使用“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

强者自强 2024-10-24 00:12:03
AttributeError: 'module' object has no attribute 'BeautifulSoup'

看来你需要安装BeautifulSoup:

sudo apt-get install python-beautifulsoup

PS。您已在 /usr/local 中安装了 feedparse 的一个版本。
还有一个用于 feedparser 的 Ubuntu 软件包:python-feedparser。它可能不是新的,但安装它会为您引入所有依赖项。

AttributeError: 'module' object has no attribute 'BeautifulSoup'

It looks like you need to install BeautifulSoup:

sudo apt-get install python-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.

梦与时光遇 2024-10-24 00:12:03

你好!我在 feedparser 5.0.1 中没有看到这个;我的猜测是 BeautifulSoup 安装得很奇怪,或者您正在运行的 feedparser 代码已被以某种方式修改。特别是,如果未安装 BeautifulSoup,微格式解析代码永远不会运行,因此达到这一点然后发现模块中没有 BeautifulSoup 类是......奇怪的。

如上所述,当您运行 Python 解释器并简单地键入时,您会得到什么

import BeautifulSoup
print BeautifulSoup.__file__
dir(BeautifulSoup)
BeautifulSoup.BeautifulSoup

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

import BeautifulSoup
print BeautifulSoup.__file__
dir(BeautifulSoup)
BeautifulSoup.BeautifulSoup
坏尐絯℡ 2024-10-24 00:12:03

我将分享我如何修复此错误:
我在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文