python - 转换为 Python 2.7 后图像服务出现错误

标签 python google-app-engine

我正在将应用程序从 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”方法也会产生相同的错误。

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

最佳答案

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

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

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

关于python - 转换为 Python 2.7 后图像服务出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12205464/

相关文章:

python - *(解包)运算符可以在 Python 中输入吗?或者任何其他可变参数函数使得所有可变类型都在结果类型中?

Python - 找不到 get-pip.py

python - 具有函数的复合 UniqueConstraint

python - 泡沫:谷歌应用引擎支持

google-app-engine - 用于应用引擎的 Stackdriver 与 ELK

Python 3.6 字符串输入

python - 不使用虚拟环境安装无污染 pip 包的最佳实践

google-app-engine - 在 Google App Engine app.yaml 中反转 skip_files

python - 在 Google Cloud Datastore 与 Google Cloud Bigtable 中存储用户事件历史记录

java - 在 Google App Engine Java 服务器中存储凭据