Python code runs in laptop's dev_appserver, but won't run in GAE :(

57 views
Skip to first unread message

ya...@pitch.studio

unread,
Oct 4, 2018, 10:17:00 AM10/4/18
to Google App Engine
Dear GAE experts -- I'm just learning the environment and hope someone can bail me out of this situation:

I have a tiny python script (that I cut and paste from the hello-world example and some others)
I got it to work on my laptop (that has all the SDKs, token, etc. loaded)
After gcloud app deploy, I get 500
Stackdriver : setting a point on the very first line of main.py tells me that it doesn't even get there
So something's wrong with the lib's etc.
Anyone ever seen this? any clue?
Here's my requirements.txt:
flask==1.0.2
requests==2.19.1
requests_toolbelt==0.8.0
oauth2client==4.1.2
functools32==3.2.3.post2; python_version < "3"

THANK YOU

dustin...@google.com

unread,
Oct 4, 2018, 11:19:28 AM10/4/18
to Google App Engine
Hi there,

It sounds like you're deploying a Python 2 app, but specifying dependencies via a `requirements.txt` file is only supported with the App Engine Python 3 runtime.

To use third-party dependencies with the Python 2 runtime, you'll need to bundle them with your application. See this guide for instructions: https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27

Dustin

ya...@pitch.studio

unread,
Oct 4, 2018, 4:27:58 PM10/4/18
to Google App Engine
Dustin:

You are spot on. Working like a charm.

Before I leave the thread --
What was missing initially (that led to requirements.txt) were httplib2 and oath2client.
Noting that they are not bundled by default (per the link you sent), I just want to make sure I am using the right libs, and I shouldn't use something else.
The operation I'm trying to accomplish is to simply read a Firebase RTDB item, like this (and I understand that only HTML is supported in GAE?):

def _get_http():
    http = httplib2.Http()
    creds = GoogleCredentials.get_application_default().create_scoped(
        _FIREBASE_SCOPES)
    creds.authorize(http)
    return http

def firebase_get(path):
    response, content = _get_http().request(path, method='GET')
    return json.loads(content)

Once again, thank you for solving this with a blink of an eye, you're awesome.

Yanay

sami...@google.com

unread,
Oct 5, 2018, 7:22:12 PM10/5/18
to Google App Engine

Thank you for your message.


I was able to deploy the application through the same article that you have been using to connect to Firebase RealTime Database and to read item from it through the HTTP request. So, this way I confirmed that you will not have any issues with using the provided code.


Regarding the question whether only HTML is supported in App Engine, did you mean HTTP requests? If so, then App Engine supports various methods to connect to different platforms. You just need to use the appropriate library in order to use another method of connection.


Reply all
Reply to author
Forward
0 new messages