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

后端 未结 2 1966
無奈伤痛
無奈伤痛 2020-12-17 03:06

I am trying to write a test for my GAE programme which uses the datastore. Following Google\'s Documentation, I see that I should be adding the path to my SDK into my PYTHON

相关标签:
2条回答
  • 2020-12-17 03:13

    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`
    
    0 讨论(0)
  • 2020-12-17 03:15

    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.

    0 讨论(0)
提交回复
热议问题