AttributeError:模块“ google.cloud.vision”没有属性“ Client”

时间:2018-11-26 18:03:35

标签: python python-3.x google-cloud-platform vision-api

**请帮我一个简单的脚本,以python实现google vision API。

我安装了我需要的所有要求,但仍然看到该错误**

AttributeError:模块'google.cloud.vision'没有属性'Client'

  

回溯(最近通话最近):文件   “ C:/Users/TAKWA/Desktop/vision/44.py”,第4行,在       vision_client = vision.Client()AttributeError:模块'google.cloud.vision'没有属性'Client'


import io
from google.cloud import vision

vision_client = vision.Client('my-key')
file_name = '1.jpg'

with io.open(file_name, 'rb') as image_file:
    content = image_file.read()
    image = vision_client.image(
        content=content, )

labels = image.detect_labels()
for label in labels:
    print(label.description)

1 个答案:

答案 0 :(得分:2)

vision_client = vision.Client('my-key')

应该是

vision_client = vision.ImageAnnotatorClient()

https://cloud.google.com/vision/docs/libraries#using_the_client_library