在model.py中导入GAE API时出错

时间:2012-08-14 16:30:49

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

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

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)

哪个工作正常。我得到了我想要的结果。但是,每当我尝试syncdb时,它都会给我一个错误:

$ python manage.py syncdb Traceback(最近一次调用最后一次):文件“manage.py”,第14行,在execute_manager(设置)文件中“/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/资源/ GoogleAppEngine-default.bundle / Contents / Resources / google_appengine / lib / django_1_3 / django / core / management / init .py“,第379行,执行self.fetch_command(子命令).run_from_argv( self.argv)在run_from_argv self中的文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_1_3/django/core/management/base.py”,第191行.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_app_errors()中的(app_name,error)get_validation_errors中:items():File”/ 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 models = 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 导入(名称)文件”/ 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 import blobstore文件”/Applications/GoogleAppEngineLauncher.app/Contents/Resources/Goog leAppEngine-default.bundle / Contents / Resources / google_appengine / google / appengine / api / blobstore / init .py“,第23行,来自blobstore import *文件”/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 import datastore_query文件”/Applications/GoogleAppEngineLauncher.app/Contents/Resources /GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/datastore/datastore_query.py“,第64行,来自google.appengine.datastore import 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行,导入yaml ImportError:没有名为yaml的模块

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

1 个答案:

答案 0 :(得分:0)

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

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