0

**帮我用这个简单的脚本在 python 中实现 google vision API。

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

AttributeError:模块“google.cloud.vision”没有属性“客户端”

Traceback(最近一次通话最后一次):文件“C:/Users/TAKWA/Desktop/vision/44.py”,第 4 行,位于 vision_client = vision.Client() AttributeError: module 'google.cloud.vision' has no attribute '客户'


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)
4

1 回答 1

2

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

应该

vision_client = vision.ImageAnnotatorClient()

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

于 2018-11-26T18:13:14.787 回答