如何在 Windows 计算机上使用 remote_api_shell 访问 appengine 数据存储区?

发布于 2025-01-03 19:39:42 字数 1348 浏览 4 评论 0原文

我目前正在尝试使用remote_api_shell.py 访问我的应用程序,如appengine 中所述:http:// /code.google.com/appengine/articles/remote_api.html。我在 Windows 7 中使用 python 27,并且能够访问 shell - 例如,我已经远程清除了内存缓存。我在访问数据存储时遇到错误,

no module found named <module name>

我的目录结构类似这样

/app.yaml
/main.py
/users/models.py

在 Windows shell 中,我键入以下内容(根据上面链接中的演练)

C:\Users\user>remote_api_shell.py -s appname.appspot.com
App Engine remote_api shell
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)]
The db, users, urlfetch, and memcache modules are imported.
s~appname> import appname
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named appname
s~appname> from google.appengine.ext import db
s~appname> from users.models import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named users.models
s~appname> from users import models
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named users

我尝试了一些不同的迭代,但似乎无法访问任何我的数据。我还尝试访问目录 /website/models.py 中的另一个模型,但也没有成功。关于如何让它发挥作用有什么想法吗?干杯。

I'm currently trying to access my app using remote_api_shell.py as documented in appengine at http://code.google.com/appengine/articles/remote_api.html. I am using python 27 in windows 7 and I am able to access the shell - I've remotely cleared the memcache for example. I am having trouble accessing the datastore with the error

no module found named <module name>

My directory stucture something like this

/app.yaml
/main.py
/users/models.py

In the windows shell I type the following (in accordance with the walkthrough at the above link)

C:\Users\user>remote_api_shell.py -s appname.appspot.com
App Engine remote_api shell
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)]
The db, users, urlfetch, and memcache modules are imported.
s~appname> import appname
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named appname
s~appname> from google.appengine.ext import db
s~appname> from users.models import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named users.models
s~appname> from users import models
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named users

I've tried a few different iterations but just cannot seem to access any of my data. I've also tried to access another model in a directory /website/models.py but also no success. Any ideas on how to get this to work? cheers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哑剧 2025-01-10 19:39:42

尝试设置模块搜索路径以包含应用程序所在的目录。这可以通过设置环境变量 PYTHONPATH 来完成(尽管我忘记了如何在 Windows 上执行此操作),或者在 shell 会话中通过附加到 sys.path 来完成。

原因是,remote_api_shell 脚本与您的应用程序位于不同的目录中,因此它的目录会添加到路径中,而不是您应用程序的目录,即使后者是当前目录。

我想你也可以将remote_api_shell.py复制到你的应用程序目录中......

Try setting the module search path to include the directory where your app lives. This can either be done by setting the environment variable PYTHONPATH (though I've forgotten how to do this on Windows), or, inside your shell session, by appending to sys.path.

The reason is that the remote_api_shell script lives in a different directory than your app, so its directory gets added to the path instead of your app's directory, even if the latter is the current directory.

I guess you could also copy remote_api_shell.py into your app directory...

撩人痒 2025-01-10 19:39:42

显然你可以将 models.py 复制到 remote_api_shell.py 目录{:^)

Obviously you can copy the models.py into remote_api_shell.py directory {:^)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文