Can't import Flask while using Google App Engine

前端 未结 5 532
闹比i
闹比i 2021-01-01 04:12

I\'m following this guide and trying to develop a Flask app to run on the Google App Engine. I followed the guide to the letter but when I launch the dev app server from the

5条回答
  •  [愿得一人]
    2021-01-01 04:42

    tldr: use appengine_config.py and copy your virtualenv to a folder called lib, then make SURE you are running the app via dev_appserver.py

    (the below is via bash in ubuntu) SO after a long battle, I find that virtual env and gcloud dont play nice -

    I copied everything from my virtual env dir

    .../.virtualenvs/nimble/local/lib/python2.7/site-packages
    

    into

    [projectdir]/lib
    

    and my appengine_config.py finally worked locally like it does in the cloud, but I absolutely HAVE to run

    dev_appserver.py [my proj dir here]
    

    or the google.appengine module wont load. did not know I should be using dev server. I feel very dumb.

    for reference, heres the appengine_config.py

    """`appengine_config` gets loaded when starting a new application instance."""
    
    print 'running app  config yaya!'
    
    from google.appengine.ext import vendor
    vendor.add('lib')
    print 'I am the line after adding lib, it should have worked'
    import os
    print os.getcwd()
    

提交回复
热议问题