AttributeError: module 'google.cloud.vision' has no attribute 'Client'

1.6k views Asked by At

**help me this a simple script to implement google vision API in python .

i installed all requirements i need but still see that error**

AttributeError: module 'google.cloud.vision' has no attribute 'Client'

Traceback (most recent call last): File "C:/Users/TAKWA/Desktop/vision/44.py", line 4, in vision_client = vision.Client() AttributeError: module 'google.cloud.vision' has no attribute '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

There are 1 answers

0
jhomr On

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

Should be

vision_client = vision.ImageAnnotatorClient()

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