Question

After somes problems with a simple import of httplib2 (see my post here), i meet a different problem with the import of gflags.

In fact, on dev server, i have an ImportError the first time that I lanch the apps. But, if i refresh the browser, the apps works ! If i looking in logs, i can see :

...
ImportError: No module named gflags
[App Instance] [0] [dev_appserver.py:2891] INFO "GET / HTTP/1.1" 500 -
[App Instance] [0] [py_zipimport.py:148] INFO zipimporter('/usr/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg', '')
[App Instance] [0] [py_zipimport.py:148] INFO zipimporter('/usr/lib/python2.5/site-packages/python_gflags-2.0-py2.5.egg', '')

So, the apps works after a refresh on dev server but it doesn't work at all after an upload on appspot :

<type 'exceptions.ImportError'>: No module named gflags
Traceback (most recent call last):
  File "/base/data/home/apps/s~yoyocontacts/2.358733066847060730/main.py", line 33, in <module>
from apiclient.discovery import build
  File "/base/data/home/apps/s~yoyocontacts/2.358733066847060730/apiclient/discovery.py", line 48, in <module>
from apiclient.http import HttpRequest
  File "/base/data/home/apps/s~yoyocontacts/2.358733066847060730/apiclient/http.py", line 47, in <module>
from model import JsonModel
  File "/base/data/home/apps/s~yoyocontacts/2.358733066847060730/apiclient/model.py", line 27, in <module>
import gflags

My application is this HelloWorld :

lrwxrwxrwx 1 yoyo   77 2012-05-06 16:24 apiclient -> /home/yoyo/dev/outils/google_appengine/lib/google-api-python-client/apiclient/
-rw-r--r-- 1 yoyo  169 2012-05-06 16:19 app.yaml
-rw-r--r-- 1 yoyo  358 2012-05-06 15:20 client_secrets.json
lrwxrwxrwx 1 yoyo   60 2012-05-07 12:12 gflags -> /home/yoyo/dev/outils/google_appengine/lib/python-gflags/
-rw-r--r-- 1 yoyo  554 2012-03-02 20:00 grant.html
lrwxrwxrwx 1 yoyo   60 2012-05-06 16:20 httplib2 -> /home/yoyo/dev/outils/google_appengine/lib/httplib2/httplib2/
-rw-r--r-- 1 yoyo  471 2012-03-02 20:00 index.yaml
-rw-r--r-- 1 yoyo 3,4K 2012-05-07 11:45 main.py
lrwxrwxrwx 1 yoyo   56 2012-05-06 16:24 oauth2 -> /home/yoyo/dev/outils/google_appengine/lib/oauth2/oauth2/
lrwxrwxrwx 1 yoyo   80 2012-05-07 10:59 oauth2client -> /home/yoyo/dev/outils/google_appengine/lib/google-api-python-client/oauth2client/
-rwxr-xr-x 1 yoyo  163 2012-05-07 11:14 run*
-rwxr-xr-x 1 yoyo  115 2012-05-07 11:50 upload*
lrwxrwxrwx 1 yoyo   79 2012-05-06 16:24 uritemplate -> /home/yoyo/dev/outils/google_appengine/lib/google-api-python-client/uritemplate/
-rw-r--r-- 1 yoyo  102 2012-03-02 20:00 welcome.html

My questions :

  • Why zipimporter works only after a refresh ?
  • How fix this error on appspot ?
Was it helpful?

Solution

Thans @greg.

I added __init__.py with import gflags then I modified apiclient/model.py with from gflags import gflags instead of just import gflags.

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