简体   繁体   中英

google-app-engine firebase-admin python

I'm attempting to setup firebase-admin with google-app-engine standard python. My dev environment is windows and I've followed the library setup as indicated in how to install 3rd party libraries. The firebase website indicates that firebase-admin has been tested on app engine, but there are no instructions or indication as to whether it was tested in standard, flexible or both. I've started with the most basic example and just tried the first import from the firebase generic documentation.

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)

The result is

ImportError: The requests library is not installed, please install the requests package to use the requests transport.

The requests library in lib during the install of firebase-admin so I'm not sure why I get this message. If I add import requests immediately before import firebase_admin I will instead get this message.

ImportError: No module named _winreg

I'd like to use firebase-admin if at all possible so if anyone is familiar with this situation and how to resolve it please let me know. Also, I am not interested in using the flexible environment, this is a question for the standard environment only.

-Install necessary modules under lib; pip install -t lib/ firebase-admin pip install -t lib/ requests-toolbelt

-you can delete the .pyc files as they are just the precompiled versions of the .py files that are also there (and will be regenerated when .py is executed).

-add below code in added the appengine_config.py;

from google.appengine.ext import vendor vendor.add('lib')

import requests import requests_toolbelt.adapters.appengine

requests_toolbelt.adapters.appengine.monkeypatch()

import platform

def patch(module): def decorate(func): setattr(module, func.func_name, func) return func return decorate

@patch(platform) def platform(): return 'AppEngine'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM