Question

I want to use the Google Calendar API for my Google App Engine webapp. I followed the instructions here (https://developers.google.com/google-apps/calendar/instantiate) for configuring the app, which required that I import gflags. I downloaded gflags here (https://code.google.com/p/python-gflags/downloads/list) and unzipped it into the same directory as main.py of my webapp. I then set up gflags by running "Python setup.py install" in command line. The set up was successful, and the following was displayed:

Installed c:\python27\lib\site-packages\python_gflags-2.0-py2.7.egg

Processing dependencies for python-gflags==2.0

Finished processing dependencies for python-gflags==2.

But this line still doesn't work:

 import gflags

I get the following error in the log:

NotImplementedError: The gflags library must be installed to use tools.run(). Please install gflags or preferrably switch to using tools.run_flow()

But I thought I already installed gflags? I'm also confused as to why setup.py created a Python egg in my c:\python27\lib folder, does that mean that Google App Engine won't be able to access it?

Was it helpful?

Solution

You're on the right track, but they python setup procedure is screwing you up; it doesn't work well with GAE.

When you deploy an app on GAE, it'll upload your entire project folder to the GAE servers. All your libraries must be inside your project folder, or else they'll be missing when running on the GAE servers.

When you install a python library though, it's usually in an installable package with the actual library plus some installer code, test code, etc. The actual library code usually is in a subfolder of what's actually unzipped. Running the setup copies the library into your global python library, which is useless for GAE.

So what you need to do is copy the actual gflags library itself into your GAE project folder. I took a quick look, and I'm guessing all your really need is to copy gflags.py and gflags_validators.py from the egg into your GAE project folder. The rest appears unnecessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top