I am trying to process some data with lxml. It works fine on my development server, but on production the following code:
parser = etree.XMLParser(encoding='cp1251')
throws:
File "parser.pxi", line 1288, in lxml.etree.XMLParser.__init__ (third_party/apphosting/python/lxml/src/lxml/lxml.etree.c:77726)
File "parser.pxi", line 738, in lxml.etree._BaseParser.__init__ (third_party/apphosting/python/lxml/src/lxml/lxml.etree.c:73404)
LookupError: unknown encoding: 'cp1251'
I am using lxml 2.3. The same version seems to be supported by GAE. So why is this error?
Edit:
I specified different encodings to XMLParser, such as cp1252, ISO-8859-5, ISO-8859-2 and it always throwed the same error on GAE, but works on my local machine. These are popular encodings and lxml on GAE must support them. I believe this is something wrong with lxml build on GAE.
I created an issue: http://code.google.com/p/googleappengine/issues/detail?id=7315
Edit2:
Full traceback:
unknown encoding: 'cp1251'
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~my_cool_app_id/1.358126884781269352/main.py", line 29, in get
parser = etree.XMLParser(encoding='cp1251')
File "parser.pxi", line 1288, in lxml.etree.XMLParser.__init__ (third_party/apphosting/python/lxml/src/lxml/lxml.etree.c:77726)
File "parser.pxi", line 738, in lxml.etree._BaseParser.__init__ (third_party/apphosting/python/lxml/src/lxml/lxml.etree.c:73404)
LookupError: unknown encoding: 'cp1251'
There seems to be a bug open about this behavior on OS X where specifying encoding="cp1252" resulted in the error above. The comments also specify other systems as affected: https://bugs.launchpad.net/lxml/+bug/707396
Have you tried specifying other encoding types? (to see if it's just a problem with cp1252)
Related
Currently I'm testing appengine-crowdguru-python this app by sending xmpp messages from http://localhost:8000/xmpp which has a form to post data .. I have filled from, to, chat (message) fields.
From : avinash#app-live.appspotchat.com
To : ajin#app-live.appspotchat.com
Chat: /tellme Who is Clinton?
where app-live app-id is currently on live. I also changed from and to fields to the ids like avi#xmpp.jp where this account is created through https://www.xmpp.jp/signup but it still shows invalid JID..
ERROR 2016-06-06 08:45:32,157 wsgi.py:280]
Traceback (most recent call last):
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 268, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/gemini/softwares/google_appengine/google/appengine/ext/webapp/xmpp_handlers.py", line 63, in handle_exception
super(BaseHandler, self).handle_exception(exception, debug_mode)
File "/home/gemini/softwares/google_appengine/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/home/gemini/PycharmProjects/appengine-crowdguru-python/guru.py", line 222, in post
super(XmppHandler, self).post()
File "/home/gemini/softwares/google_appengine/google/appengine/ext/webapp/xmpp_handlers.py", line 73, in post
self.message_received(self.xmpp_message)
File "/home/gemini/softwares/google_appengine/google/appengine/ext/webapp/xmpp_handlers.py", line 118, in message_received
handler(message)
File "/home/gemini/PycharmProjects/appengine-crowdguru-python/guru.py", line 302, in tellme_command
message.reply(WAIT_MSG)
File "/home/gemini/softwares/google_appengine/google/appengine/api/xmpp/__init__.py", line 515, in reply
message_type=message_type, raw_xml=raw_xml)
File "/home/gemini/softwares/google_appengine/google/appengine/api/xmpp/__init__.py", line 346, in send_message
raise InvalidJidError()
InvalidJidError
A common behaviour of "get Jid" it's error if Resource (in login phase) it's not definied due to the Jid composition ( user # server /resource). A "full jid" it's complete of Resource, so if it's null you can have a null pointer and so an error.
How to handle:
SOLUTION 1: retrive just "bare Jid"
SOLUTION 2: define a resource (it's a custom name that represent your client).
Hope that's help.
I'm trying to run an application for AppEngine with python where I'm import the example module to get data from Google Analytics https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py but when I run the server with dev_appserver.py and go to localhost:8080/ I recive an 505 error with his error in the console:
Traceback (most recent call last):
File "/home/ingdavid/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/home/ingdavid/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/home/ingdavid/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/ingdavid/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/home/ingdavid/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/ingdavid/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/var/www/repositorios/PYTHON/dashboard/app.py", line 248, in get
print analyticsH.main()
File "/var/www/repositorios/PYTHON/dashboard/analyticsH.py", line 111, in main
service_account_email)
File "/var/www/repositorios/PYTHON/dashboard/analyticsH.py", line 35, in get_service
scope=scope)
File "/var/www/repositorios/PYTHON/dashboard/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/var/www/repositorios/PYTHON/dashboard/oauth2client/client.py", line 1503, in __init__ _RequireCryptoOrDie()
File "/var/www/repositorios/PYTHON/dashboard/oauth2client/client.py", line 1457, in _RequireCryptoOrDie
raise CryptoUnavailableError('No crypto library available')
CryptoUnavailableError: No crypto library available
I've searched and all that I've found is install openssl or install python-crypto or update python-dev, I doing everything but not works.
Thank you.
I'm trying to look into a subdirectory to obtain all unicode filenames in App Engine, but it gives me this instead. It works, however, when the subdirectory is filled with non-unicode filenames.
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~theonlyrt6/1.372787192964623739/main.py", line 69, in get
'titles' : os.listdir("./Articles")
OSError: [Errno 2] No such file or directory: './Articles'
This is my code:
template_values = {
'titles' : os.listdir("./Articles")
}
template = jinja_environment.get_template('HTML/Articles.html')
self.response.write(template.render(template_values))
The sub-directory is not uploaded as a static directory and it works when run locally.
Thanks!
Based on the example jinja app, the html files appears to uploaded automatically.
We've been getting this very frequently lately, on various queries that have worked fine until recently. Here's the full traceback:
...
File "/base/data/home/apps/s~hebkhan/16.370010861782528881/models.py", line 2548, in search_tree
contentItems = db.get(contentKeys)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1533, in get
return get_async(keys, **kwargs).get_result()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 844, in get_result
result = rpc.get_result()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
return self.__get_result_hook(self)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1482, in __get_hook
self.check_rpc_success(rpc)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1234, in check_rpc_success
rpc.check_success()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 578, in check_success
self.__rpc.CheckSuccess()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
Error: An error occurred for the API request datastore_v3.Get().
I've seen similar issues being mentioned but nowhere was there any hint to the source of the problem.
I should also mention that this app is using python2.5 and we've yet to make the transition to python2.7. However, I don't think the could be related since the error comes from an RPC call that occurs in the Datastore.
I am using the followng wordpress xmlrpc module written in python:
But when I run the program I get the following error.You have any idea of how to solve this program??Here is the error that I get
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
wp.call(NewPost(post, True))
File "C:\Python27\lib\site-packages\wordpress_xmlrpc\base.py", line 27, in call
raw_result = server_method(*args)
File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "C:\Python27\lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "C:\Python27\lib\xmlrpclib.py", line 1467, in parse_response
p.feed(data)
File "C:\Python27\lib\xmlrpclib.py", line 557, in feed
self._parser.Parse(data, 0)
ExpatError: junk after document element: line 2, column 0
This error usually occurs when the response to your call is not valid XML. For example, if it begins with a newline, like this:
\n<?xml version="1.0"?>\n<methodResponse>\n<params>\n<param>\n<value>\n
<array><data>\n <value><string>wp.getUsersBlogs</string></value>
Some versions of WordPress (or some installed plugins) seem to have this issue. Unfortunately, that means the issue is not in your code but with the WordPress instance you are communicating with.