【问题标题】:connect to google datastore from Python [duplicate]从 Python 连接到谷歌数据存储 [重复]
【发布时间】:2012-11-16 19:16:14
【问题描述】:

可能重复:
PyDev project for Google App Engine not finding webapp2

我正在学习 helloworld 教程,无法从 Python 连接;

这是 app.yaml 文件:

application: "ceemee11111"
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:


- url: /.*
  script: helloworld.app

builtins:
- remote_api: on

这是 helloworld.py 的开始:

import cgi
import datetime
import urllib
import webapp2

from google.appengine.ext import db
from google.appengine.api import users


class Greeting(db.Model):
      """Models an individual Guestbook entry with an author, content, and date."""
      author = db.StringProperty()
      content = db.StringProperty(multiline=True)
      date = db.DateTimeProperty(auto_now_add=True)

在 Python shell 中我 chdir 到 helloworld 导入你好世界

并得到导入错误“没有名为 webapp2 的模块”

应用程序在 localhost 和 ceemee11111.appspot.com 中运行,没有错误。 作为测试,我注释掉了“import webapp2”并再次尝试并得到了错误 “没有名为 google.appengine.ext 的模块”

请给点意见

应用

【问题讨论】:

    标签: python export google-cloud-datastore


    【解决方案1】:

    好像python找不到库,所以

    • 你在系统中安装了 webapp2 吗?您可以尝试使用“pip install webapp2”或“easy_install”

    • 如果它们仍然丢失,也许你应该检查你的“PYTHONPATH”变量,检查 python 在哪里寻找库,并将你的添加到路径中。

    【讨论】:

    • 我认为如果该应用程序可以在 localhost 和 appspot.com 上运行,那么这些模块将可用。 webapp2 不在 python 的可用模块中,所以我将尝试安装它。
    • 我已经在 python 的模块中安装了 webapp2 并再次运行 import helloworld 并得到“导入错误:没有名为 webob 的模块”
    • 这对于一个基本过程来说似乎非常复杂。我所需要的只是让 put() 和 fetch() 访问谷歌数据存储以获取和检索数据。有没有更简单的方法来做到这一点。
    • 好的,这开始有意义了。 google 有自己的 /lib 模块,python 有自己的 /lib 模块。我已经安装了 pip,我可以去 google/lib 并运行 $ pip freeze -E [env1] > requirements.txt 然后去 python/lib 并运行 $ pip install -E [env2] -r /path/ to/requirements.txt 如果是的话 /path/to/requirtments.txt 是什么
    • 我所要做的就是将 c:\....\google_appengine 添加到路径变量以使用 google lib 而不是 python lib
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2018-12-18
    相关资源
    最近更新 更多