Search code examples
pythongoogle-app-engineyamljinja2webapp2

ImportError: cannot import name parsedate_tz - jinja2


I have been working with Google App Engine python version to create very simple websites.

It was working fine for a while but then recently I have been getting the following error:

bad runtime process port ['']
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 82, in <module>
    _run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 78, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  ...
  ... some more errors
  ...
  ...
  File "C:\Users\Shashank\Desktop\apps\calendar.py", line 2, in <module>
    import webapp2
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.3\webapp2.py", line 24, in <module>
    import webob
  File "C:\Program Files (x86)\Google\google_appengine\lib\webob-1.1.1\webob\__init__.py", line 1, in <module>
    from webob.datetime_utils import *
  File "C:\Program Files (x86)\Google\google_appengine\lib\webob-1.1.1\webob\datetime_utils.py", line 4, in <module>
    from email.utils import parsedate_tz, mktime_tz, formatdate
ImportError: cannot import name parsedate_tz

I checked in C:\Python27\Lib\email\utils.py and it does contain a method called parsedate_tz. Furthermore, my current working directory of my script does not contain any file called utils.py or email.py.

So, I can't understand where my problem lies. I have also looked online and at developers.google.com but to no avail.

Perhaps, I should also tell you that the error started showing up after I started using jinja2 but I don't know if that is just coincidence or that they're somehow related.

Thank you for your help.

Here are my app.yaml and calendar.py files but I doubt that the error lies there:

#app.yaml
application: block-scheduler
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: calendar.application


#calendar.py
import os
import webapp2

code = """
<p>Test</p>
"""

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.out.write(code)

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

Solution

  • Make sure you import the webob library in app.yaml:

    libraries:
    - name: webob
      version: "1.1.1"  # or "1.2.3" or "latest"