According to the Google AppEngine documentation, one should import memcache like this:
from google.appengine.api import memcache
I’m using a virtualenv and I’m creating some scripts to test a library I created for AppEngine. I am not trying to test a website, I am trying to test a specific library that uses memcache. Evidently, without using dev_appserver.py I get an ImportError: No module named google.appengine.api.
I had a look at the source of dev_appserver.py but first I’d like to know if there is a simpler solution that would not require rewriting PATH as Google does.
Thanks!
There is no simple solution, at the minimum you’ll have to setup your Python paths. That’s all the dev_appserver wrapper you linked to does. For testing code / libraries I usually write a simple wrapper that does basically the same thing as dev_appserver is doing.
In some cases you’ll actually need to go a step further and initialize the stubs as well. If you follow through the dev_appserver code, you’ll be able to see how this is done.