设置我的远程API
我的应用需要一个备份系统和远程管理功能,所以我关闭了联合登录,这样可以更方便地访问远程API。现在我可以登录了,但我无法导入我的模块:
montao$ python ./remote_api_shell.py -s montaoproject.appspot.com
Email: niklasro
Password:
App Engine remote_api shell
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2]
The db, users, urlfetch, and memcache modules are imported.
s~montaoproject> import i18n
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named i18n
s~montaoproject>
你能告诉我怎么运行一些简单的远程API命令吗?我可以通过/python 2.7运行备份系统,并通过/_ah/remote.api连接,所以我的设置看起来是正确的,我可能只是需要更清楚地理解如何使用远程API。
更新
这个方法有效,但似乎使用的是django 0.96:
ubuntu@ubuntu:/media/Lexar/montao$ PYTHONPATH=./montaoproject python ./remote_api_shell.py -s montaoproject.appspot.com
App Engine remote_api shell
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2]
The db, users, urlfetch, and memcache modules are imported.
s~montaoproject> import i18n
WARNING:root:You are using the default Django version (0.96). The default Django version will change in an App Engine release in the near future. Please call use_library() to explicitly select a Django version. For more information see http://code.google.com/appengine/docs/python/tools/libraries.html#Django
s~montaoproject>
1 个回答
4
在你的命令前面加上 PYTHONPATH=.
(或者把 .
替换成你应用所在的文件夹)。如果不告诉Python去哪里找模块,它就不知道该去哪里找,而默认情况下,当前文件夹并不在搜索路径里。