6

Python 2.7.6, Google APIs Client Library for Python for Google App Engine, Google Developer's Guide

I'm going through the Google documentation, and trying to duplicate their example. When I run the command:

from google.appengine.ext import webapp

from Python Shell, I get the error msg:

No module named google.appengine.ext

So obviously, that file is not on my computer. I've done searches for the file on my hard drive and haven't found anything. I've run easy_install to install the Google API as instructed in the official Google Quick Start video. I'm not sure if Google's documentation is now outdated, or what is happening. Where do I get the google.appengine.ext? I'm assuming that my problem is simply that I don't have that module.

Alan Wells
  • 30,746
  • 15
  • 104
  • 152
  • 1
    Please see my answer here: ["GAE Running Locally"](http://stackoverflow.com/questions/38195967/google-app-engine-error-when-running-dev-appserver-py-no-module-named-appeng/38196084#38196084 ) – mtisz Jul 05 '16 at 06:00

4 Answers4

4

You may need to add the following line, incase you are running stand alone tests

 sys.path.append('/usr/local/google_appengine/')
 sys.path.append('/usr/local/google_appengine/lib/yaml/lib/')
 if 'google' in sys.modules:
     del sys.modules['google']
varun
  • 4,522
  • 33
  • 28
  • This solution don't work for my. I'm trying `from google.appengine.ext import ndb` without dev_server and I don't find why. Any idea? – Juan Antonio Jun 06 '16 at 16:01
  • Just edited my answer (added sys.modules['google']). Try this – varun Jun 07 '16 at 14:45
  • I Just try this, and doesn't work for me. Maybe I have other problems, I only want try the Google Datastore without the devserver runnig. – Juan Antonio Jun 08 '16 at 09:06
3

I've seen @varun answer in other question, and he use insert instead of append, and then this work perfectly, at least for me.

sys.path.insert(1, '<yourFolder>/google_appengine')
sys.path.insert(1, '<yourFolder>/google_appengine/lib/yaml/lib')
if 'google' in sys.modules:           
    del sys.modules['google']
Juan Antonio
  • 2,451
  • 3
  • 24
  • 34
2

App Engine samples presume that you have the App Engine SDK installed:

https://developers.google.com/appengine/downloads

https://developers.google.com/api-client-library/python/start/installation#appengine

Joe Gregorio
  • 770
  • 4
  • 7
  • Thank you. I'd actually downloaded and installed both of those, plus google-api-python-client-gae-N.M.zip And I've found the files that I think are needed. I'm guessing that the problem is the `PATH` defined on my operating system isn't pointing to those folders, so when I'm running a line of Python code in Python Shell from the folder C:\Python27 the `IMPORT` command is not finding that appengine module. It looks like I have the appengine SDK files in the `PROGRAM FILES\GOOGLE\GOOGLE_APPENGINE\LIB\GOOGLE-API-PHTHON-CLIENT\OATH2CLIENT` folder. I'm guessing that got set up with Launcher. – Alan Wells Jan 02 '14 at 19:07
  • 1
    For App Engine you need to run your code within the development web server: https://developers.google.com/appengine/docs/python/tools/devserver. Once that's running you can use the interactive console provided: https://developers.google.com/appengine/docs/python/tools/devserver#Python_The_Interactive_Console – Joe Gregorio Jan 02 '14 at 19:39
  • 1
    I have used App Engine Launcher, which has a `BROWSE` button that opens my app in my web brower at `http://localhost:8080/`. I'm assuming that is the same as running the command line: `dev_appserver.py myapp` – Alan Wells Jan 02 '14 at 21:02
  • @JoeGregorio PLEASE make this the answer!! I spent 4 hours looking for this.... the sample code makes it look like the SDK auto installs a bunch of modules you can just test and use normally!! – Vincent Buscarello Dec 24 '16 at 19:43
-2

The google.appengine.ext means google/appengine/ext it is just like the packages directory in Eclipse