2

我正在将应用程序从 Python 2.5 切换到 2.7,并且开始遇到图像服务问题。例如,使用 db.put() 保存此实体:

from google.appengine.api import images

class Images(db.Expando):
    ImageTitle = db.StringProperty()
    ImageFile = blobstore.BlobReferenceProperty()
    ImageReference = db.StringProperty()

    def put(self, **kwargs):                    
        if not self.ImageReference:
            self.ImageReference = images.get_serving_url(self.ImageFile.key())
        super(Images, self).put(**kwargs)

现在产生此错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1536, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\Users\VB User\Bruha\src\handler_product_page_image.py", line 40, in post
    image.put()
  File "C:\Users\VB User\Bruha\src\db_models.py", line 56, in put
    self.ImageReference = images.get_serving_url(self.ImageFile.key())
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\__init__.py", line 1792, in get_serving_url
    rpc = get_serving_url_async(blob_key, size, crop, secure_url, filename, rpc)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\__init__.py", line 1907, in get_serving_url_async
    None)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\__init__.py", line 1034, in _make_async_call
    rpc = create_rpc()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\images\__init__.py", line 1028, in create_rpc
    return apiproxy_stub_map.UserRPC("images", deadline, callback)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 405, in __init__
    self.__rpc = CreateRPC(service, stubmap)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 69, in CreateRPC
    'a CreateRPC method.') % service)
AssertionError: The service "images" doesn't have a CreateRPC method.

调用 'execute_transforms' 方法也会产生相同的错误。

任何帮助了解正在发生的事情将不胜感激。

4

1 回答 1

5

您正在运行开发服务器,因此在启动时检查此消息“无法初始化图像 API;您可能缺少“”Python“PIL”模块。导入错误:%s',e

如果您收到此消息,则图像服务 RPC 未注册(RegisterStub在 dev_appserver 中的调用将失败)并且您将收到您看到的错误,因为CreateRPC调用中的断言失败。

因此,请检查是否为 Python 2.7 正确安装了 PIL

于 2012-08-31T02:42:20.420 回答