如何让pyxero与Google App Engine配合使用

时间:2016-05-30 04:42:19

标签: python google-app-engine oauth webapp2

我目前正在使用最新版本的pyxero,而我似乎无法使用Google App Engine工作。下面是我的InvoiceHandler类的代码:

class InvoicesHandler(webapp2.RequestHandler):
    def get(self):
        template_values = {
            "header":"Invoices",
            "body":"Connecting to Xero API"
        }
        template = JINJA_ENV.get_template('invoices.html')
        self.response.write(template.render(template_values))
        with open("privatekey.pem") as keyfile:
            RSA_KEY = keyfile.read()
        credentials = PrivateCredentials(consumerKey, RSA_KEY)
        xero = Xero(credentials)
        xero.contacts.all()

尝试运行应用程序时出现以下错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-         2.5.2\webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\Users\neera\OneDrive\GoPomelo\go-accounting\InvoicesHandler.py", line 34, in get
    xero = Xero(credentials)
  File "C:\Users\neera\OneDrive\GoPomelo\go-accounting\xero\api.py", line 47, in __init__
    user_agent))
  File "C:\Users\neera\OneDrive\GoPomelo\go-accounting\xero\manager.py", line 21, in __init__
    self.user_agent = 'pyxero/%s ' % VERSION + requests.utils.default_user_agent()
  File "C:\Users\neera\OneDrive\GoPomelo\go-accounting\requests\utils.py", line 537, in default_user_agent
    p_system = platform.system()
  File "C:\Python27\lib\platform.py", line 1263, in system
    return uname()[0]
  File "C:\Python27\lib\platform.py", line 1159, in uname
    release,version,csd,ptype = win32_ver()
  File "C:\Python27\lib\platform.py", line 632, in win32_ver
    from _winreg import OpenKeyEx, QueryValueEx, CloseKey, HKEY_LOCAL_MACHINE
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 963, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named _winreg 

0 个答案:

没有答案