Testing a Google App Engine application from a terminal (python cli)

I run from appname import model , which gives me:

 ImportError: No module named google.appengine.api 

So, I add the following Python path (the only path I could find ):

PYTHONPATH=/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/:~/src/appname/src/ python

And then run the command again. But that tells me:

 ImportError: No module named yaml 

I am running Mac OS X Snow Leopard and the latest version of GAE. Any tips? All I want to do is run some of the methods in my model.

+4
source share
1 answer

From dev_appserver.py:

 DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) # ... EXTRA_PATHS = [ DIR_PATH, os.path.join(DIR_PATH, 'lib', 'antlr3'), os.path.join(DIR_PATH, 'lib', 'django'), os.path.join(DIR_PATH, 'lib', 'fancy_urllib'), os.path.join(DIR_PATH, 'lib', 'ipaddr'), os.path.join(DIR_PATH, 'lib', 'webob'), os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'), ] # ... sys.path = EXTRA_PATHS + sys.path 

I think it should work if you put these bits in a separate script and import it before importing your own code.

Or, as you pointed out, use the Appengine console in the SDK (but this is not the case for Linux users).

+2
source

All Articles