在简单导入httplib2之后遇到一些问题(请参阅我的帖子here),我遇到了导入gflags的不同问题。
事实上,在开发服务器上,我第一次使用应用程序时出现了ImportError。但是,如果我刷新浏览器,应用程序的工作原理!如果我查看日志,我可以看到:
...
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', '')
因此,应用程序在开发服务器上刷新后可以运行,但在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
我的申请是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
我的问题:
答案 0 :(得分:2)
Thans @greg。
我在__init__.py
添加了import gflags
,然后我使用apiclient/model.py
而非from gflags import gflags
修改了import gflags
。