I am trying to use BeautifulSoup v4 to parse a document. I call BeautifulSoup on note.content, which is the string returned by the Evernote API:
soup = BeautifulSoup (note.content)
I included lxml in my app.yaml file:
libraries: - name: lxml version: "2.3"
Please note that this works on my local development server. However, when deploying to the Google Cloud, I get the following error:
Error tracing:
Unicode parsing is not supported on this platform Traceback (most recent call last): File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__ rv = self.handle_exception(request, response, e) File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__ rv = self.router.dispatch(request, response) File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher return route.handler_adapter(request, response) File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__ return handler.dispatch() File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch return self.handle_exception(e, self.app.debug) File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch return method(*args, **kwargs) File "/base/data/home/apps/s~ever-blog/1.356951374446096208/controller/blog.py", line 101, in get soup = BeautifulSoup(note.content) File "/base/data/home/apps/s~ever-blog/1.356951374446096208/lib/bs4/__init__.py", line 168, in __init__ self._feed() File "/base/data/home/apps/s~ever-blog/1.356951374446096208/lib/bs4/__init__.py", line 181, in _feed self.builder.feed(self.markup) File "/base/data/home/apps/s~ever-blog/1.356951374446096208/lib/bs4/builder/_lxml.py", line 62, in feed self.parser.feed(markup) File "parser.pxi", line 1077, in lxml.etree._FeedParser.feed (third_party/apphosting/python/lxml/src/lxml/lxml.etree.c:76196) ParserError: Unicode parsing is not supported on this platform
UPDATE:
I checked parser.pxi and I found these lines of code that caused the error:
elif python.PyUnicode_Check(data): if _UNICODE_ENCODING is NULL: raise ParserError, \ u"Unicode parsing is not supported on this platform"
I think there should be something in the GAE deployment environment that causes this error, but I'm not sure what.
UPDATE 2:
Since BeautifulSoup automatically dips on other parsers, I completely removed lxml from my application. This fixed the problem.