python feedparser error install

4.6k views Asked by At

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,

3

There are 3 answers

0
unutbu On
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.

0
Kurt McKee On

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
0
Yogiraj Banerji On

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.