"AttributeError: 'module' object has no attribute 'parse'" error when using feedparser and Google Apps Engine

671 views
Skip to first unread message

James via StackOverflow

unread,
Apr 27, 2015, 6:58:38 AM4/27/15
to google-appengin...@googlegroups.com

Hi everyone. I'm trying to create an RSS reader with Google Apps Engine, Python and feedparser. As a first step I've tried to print the title of one article to the page.

Regardless of whether I run the program on localhost or appspot.com I get the following error:

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

My directory has the following files in it:

- feedparser.pyc
- templates
- - news.html
- main.pyc
- favicon.ico
- feedparser.py
- main.py
- app.yaml
- index.yaml

Here's my main.py code:

import os
import webapp2
import jinja2
import feedparser

template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
                           autoescape = True)

def render_str(template, **params):
    t = jinja_env.get_template(template)
    return t.render(params)

class BaseHandler(webapp2.RequestHandler):
    def render(self, template, **kw):
        self.response.out.write(render_str(template, **kw))

    def write(self, *a, **kw):
        self.response.out.write(*a, **kw)

class MainPage(BaseHandler):
    def get(self):
        post = feedparser.parse('http://www.theguardian.com/au/rss').entries[0].title
        self.render('news.html', posts = post)

app = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)

I've searched on stackoverflow and elsewhere for solutions and have already tried the following with no luck:

  • Deleting the .pyc files (they just reappear again)
  • Printing feedparser.__file__ (it points to feedparser.pyc in the right folder)

Not sure all of this is relevant but I'm using:

  • Python 2.7
  • Google App Engine Release release 1.9.19
  • Windows 7
  • Google Chrome

Thanks in advance for your time!

p.s. this is my first time posting to stackoverflow so any tips on etiquette are also welcome.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/29893705/attributeerror-module-object-has-no-attribute-parse-error-when-using-feed

James via StackOverflow

unread,
Apr 27, 2015, 5:13:59 PM4/27/15
to google-appengin...@googlegroups.com

Hi everyone. I'm trying to create an RSS reader with Google Apps Engine, Python and feedparser. As a first step I've tried to print the title of one article to the page.

Regardless of whether I run the program on localhost or appspot.com I get the following error:

Internal Server Error

The server has either erred or is incapable of performing the requested operation.

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
 File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
  File "/base/data/home/apps/s~mynews-xxxxx/1.383897364028032608/main.py", line 41, in get
posts = feedparser.parse('http://www.theguardian.com/au/rss').entries[0].title
  • I've also tried using feedparser in the Python GUI and it works fine there
Reply all
Reply to author
Forward
0 new messages