【问题标题】:Error for importing GAE API in model.py在 model.py 中导入 GAE API 时出错
【发布时间】:2012-08-11 00:11:19
【问题描述】:

在我的model.py中,我正在导入图片以生成图片的url,如下所示。

from google.appengine.api import images

class Picture(models.Model):
    picture_blob_key = models.TextField()

    def picture_url(self):
        return images.get_serving_url(self.picture_blob_key)

效果很好。我得到了我想要的结果。但是,每当我尝试同步数据库时,它都会给我一个错误:

$ python manage.py syncdb Traceback(最近一次调用最后一次):文件“manage.py”,第 14 行,在 execute_manager(settings) 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle /Contents/Resources/google_appengine/lib/django_1_3/django/core/management/init.py”,第 438 行,在 execute_manager utility.execute() 文件中“/Applications/GoogleAppEngineLauncher.app/Contents/ Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_1_3/django/core/management/init.py”,第 379 行,在执行 self.fetch_command(subcommand).run_from_argv( self.argv)文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_1_3/django/core/management/base.py”,第191行,在run_from_argv self .execute(*args, **options.dict) 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bund le/Contents/Resources/google_appengine/lib/django_1_3/django/core/management/base.py”,第 219 行,在执行 self.validate() 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default. bundle/Contents/Resources/google_appengine/lib/django_1_3/django/core/management/base.py”,第 249 行,在 validate num_errors = get_validation_errors(s, app) 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine -default.bundle/Contents/Resources/google_appengine/lib/django_1_3/django/core/management/validation.py”,第 35 行,在 get_validation_errors for (app_name, error) in get_app_errors().items():文件“/Applications /GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_1_3/django/db/models/loading.py”,第 146 行,在 get_app_errors self._populate() 文件“/Applications /GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengin e/lib/django_1_3/django/db/models/loading.py”,第 64 行,在 _populate self.load_app(app_name) 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources /google_appengine/lib/django_1_3/django/db/models/loading.py”,第 78 行,在 load_app 模型 = import_module('.models', app_name) 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default .bundle/Contents/Resources/google_appengine/lib/django_1_3/django/utils/importlib.py”,第 35 行,在 import_module import(名称)文件“/Users/taelimoh/Dropbox/gluwa_test/society /models.py”,第 10 行,从 google.appengine.api 导入图像文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/images /init.py”,第 48 行,从 google.appengine.api 导入 blobstore 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/Goog leAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/blobstore/init.py”,第 23 行,从 blobstore 导入 * 文件“/Applications/GoogleAppEngineLauncher.app/Contents /Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/blobstore/blobstore.py”,第 38 行,从 google.appengine.api 导入数据存储文件“/Applications/GoogleAppEngineLauncher.app/Contents /Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore.py”,第 62 行,从 google.appengine.datastore 导入 datastore_query 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources /GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/datastore/datastore_query.py”,第 64 行,从 google.appengine.datastore 导入 datastore_index 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine -default.bundle/目录/资源/g oogle_appengine/google/appengine/datastore/datastore_index.py”,第 60 行,从 google.appengine.api 导入验证文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/ google/appengine/api/validation.py",第 51 行,在 import yaml ImportError: No module named yaml

所以,现在我必须在使用 syncdb 时将 GAE API 导入注释掉,然后将其重新导入。任何评论都将不胜感激。

【问题讨论】:

    标签: mysql django google-app-engine django-models google-cloud-sql


    【解决方案1】:

    您收到的错误是因为 import yaml 失败。该库与 GAE 捆绑在一起,每当您启动一个工具时,它都会修复 sys 路径以便找到它。

    你可以做的是手动安装yaml包。

    【讨论】:

      猜你喜欢
      • 2011-11-24
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 1970-01-01
      • 2020-12-20
      • 2021-03-12
      相关资源
      最近更新 更多