google-app-engine firebase-admin python

时间:2017-08-07 14:43:53

标签: python google-app-engine firebase-authentication google-app-engine-python firebase-admin

我正在尝试使用google-app-engine标准python设置firebase-admin。我的开发环境是Windows,我按照如何安装第三方库的方式进行了库设置。 firebase网站指出firebase-admin已经在app引擎上进行了测试,但没有说明或指示它是在标准,灵活还是两者中进行测试。我已经开始使用最基本的示例,并尝试从firebase通用文档中首次导入。

import webapp2
import firebase_admin

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, World!')


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

结果是

  

ImportError:未安装请求库,请安装   请求包使用请求传输。

在安装firebase-admin期间lib中的请求库所以我不知道为什么我收到此消息。如果我在导入firebase_admin之前立即添加导入请求,我会收到此消息。

  

ImportError:没有名为_winreg的模块

如果可能的话,我想使用firebase-admin,如果有人熟悉这种情况以及如何解决它,请告诉我。另外,我对使用灵活环境不感兴趣,这只是标准环境的问题。

1 个答案:

答案 0 :(得分:3)

- 在lib下安装必要的模块;     pip install -t lib / firebase-admin     pip install -t lib / requests-toolbelt

- 你可以删除.pyc文件,因为它们只是同时存在的.py文件的预编译版本(并且在执行.py时会重新生成)。

-add下面的代码添加了appengine_config.py;

来自google.appengine.ext导入供应商 vendor.add( 'LIB')

导入请求 import requests_toolbelt.adapters.appengine

requests_toolbelt.adapters.appengine.monkeypatch()

导入平台

def patch(模块):     def decorate(func):         setattr(module,func.func_name,func)         返回功能     返回装饰

@patch(平台) def platform():     返回'AppEngine'