ImportError when used with Google App Engine
badersur opened this issue · 5 comments
When I try to use the library with App Engine I get this error, if I put import CommonMark at the top:
ERROR 2016-08-26 14:04:59,126 wsgi.py:263]
Traceback (most recent call last):
File "/home/super/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/super/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/super/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/super/WebProjects/myapp/blog.py", line 3, in <module>
from models import Post
File "/home/super/WebProjects/myapp/models.py", line 1, in <module>
import CommonMark
File "/home/super/WebProjects/myapp/libs/CommonMark/__init__.py", line 4, in <module>
from CommonMark.main import commonmark
File "/home/super/WebProjects/myapp/libs/CommonMark/main.py", line 15, in <module>
from CommonMark.dump import dumpAST, dumpJSON
File "/home/super/WebProjects/myapp/libs/CommonMark/dump.py", line 3, in <module>
from builtins import str
File "/home/super/WebProjects/myapp/libs/builtins/__init__.py", line 8, in <module>
from future.builtins import *
File "/home/super/WebProjects/myapp/libs/future/builtins/__init__.py", line 10, in <module>
from future.builtins.iterators import (filter, map, zip)
File "/home/super/WebProjects/myapp/libs/future/builtins/iterators.py", line 43, in <module>
from future.types import newrange as range
File "/home/super/WebProjects/myapp/libs/future/types/__init__.py", line 243, in <module>
from .newrange import newrange
File "/home/super/WebProjects/myapp/libs/future/types/newrange.py", line 25, in <module>
from future.backports.misc import count # with step parameter on Py2.6
File "/home/super/WebProjects/myapp/libs/future/backports/__init__.py", line 17, in <module>
from .misc import (ceil,
File "/home/super/WebProjects/myapp/libs/future/backports/misc.py", line 900, in <module>
from subprocess import check_output
ImportError: cannot import name check_output
INFO 2016-08-26 14:04:59,140 module.py:788] default: "GET /blog/5822463824887808 HTTP/1.1" 500 -
INFO 2016-08-26 14:04:59,196 module.py:788] default: "GET /favicon.ico HTTP/1.1" 304 -
But, when I import CommonMark inside a method I get:
ERROR 2016-08-26 13:38:08,116 webapp2.py:1552] cannot import name check_output
Traceback (most recent call last):
File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/home/super/WebProjects/myapp/blog.py", line 29, in get
self.render('permalink.html', post=post, url=self.url)
File "/home/super/WebProjects/myapp/handlers.py", line 33, in render
self.write(self.render_str(template, **kw))
File "/home/super/WebProjects/myapp/handlers.py", line 30, in render_str
return render_str(template, **kw)
File "/home/super/WebProjects/myapp/handlers.py", line 20, in render_str
return t.render(kw)
File "/home/super/google_appengine/lib/jinja2-2.6/jinja2/environment.py", line 894, in render
return self.environment.handle_exception(exc_info, True)
File "/home/super/WebProjects/myapp/templates/permalink.html", line 1, in top-level template code
{% extends "base.html" %}
ImportError: cannot import name check_output
INFO 2016-08-26 13:38:08,186 module.py:788] default: "GET /blog/5822463824887808 HTTP/1.1" 500 228
INFO 2016-08-26 13:38:08,281 module.py:788] default: "GET /favicon.ico HTTP/1.1" 304 -
I am used to add other libraries to my App Engine projects as described in App Engine's installing a library document but this library causes these errors even though it is working with webapp2 outside App Engine!
Note: I am using App Engine Standard Environment
What version of python did this occur on?
Interesting, check_output was introduced in Python 2.7. The line of code that's causing this error is here in python-future:
https://github.com/PythonCharmers/python-future/blob/master/src/future/backports/misc.py#L900
My wild guess would be that Google App Engine has a custom version of Python 2.7.12. But I know nothing about GAE, so I don't really know. In any case, I suggest opening this issue with python-future here: https://github.com/PythonCharmers/python-future/issues I think the maintainers there would find this error interesting, and could help us with the problem.
Thank you @nikolas. I'll open this issue with python-future.
Should I close the issue here or you'll close it?! It's my first time using issues!
I'll close it, and you can link to this issue from the one you create with python-future, so they have some sense of how this error came about.