Google App Engine: ImportError: No module named appengine.ext

走远了吗. 提交于 2019-11-29 05:08:49

I run into these problems a lot less by always running inside a virtualenv.

I agree with snakecharmerrb you should get print google.__file__ or google.__path_ to figure out exactly what you're importing.

This snippet might also solve your problem:

import google

gae_dir = google.__path__.append('/path/to/appengine_sdk//google_appengine/google')
sys.path.insert(0, gae_dir) # might not be necessary

import google.appengine # now it's on your import path`

Which version of app engine SDK are you using? I am using the latest SDK (1.9.34). I find the below snippet in my ~/google_appengine/google/appengine/ext/ndb/google_imports.py file

try:
    from google3.storage.onestore.v3 import entity_pb
    normal_environment = False
except ImportError:
    # If we are running locally but outside the context of App Engine.
    try:
      set_appengine_imports()
      from google.appengine.datastore import entity_pb
      normal_environment = True
    except ImportError:
      raise ImportError('Unable to find the App Engine SDK. '
                    'Did you remember to set the "GAE" environment '
                    'variable to be the path to the App Engine SDK?')

But in your stack trace, after google3.storage import it doesn't seem to go inside the except clause.

So try the same code with latest SDK.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!