I did the setup for using the Google Vision API via Python, but it doesn't work and I don't find any good solutions. No matter what I do, I always get "AttributeError: module 'google.cloud.vision' has no attribute 'types'"...
Here is an example Code I use (Authentication etc. is done).
from __future__ import print_function
from google.cloud import vision
from google.cloud.vision import types
image_uri = 'gs://cloud-samples-data/vision/using_curl/shanghai.jpeg'
client = vision.ImageAnnotatorClient()
image = types.Image(content=IMAGE_CONTENT)
label_results = client.label_detection(image=image)
response = client.label_detection(image=image)
print('Labels (and confidence score):')
print('=' * 30)
for label in label_results.label_annotations:
print(f'{label.description} - {label.score}')
Here is my pip freeze:
appdirs==1.4.3
CacheControl==0.12.6
cachetools==4.1.1
certifi==2019.11.28
chardet==3.0.4
colorama==0.4.3
contextlib2==0.6.0
distlib==0.3.0
distro==1.4.0
google-api-core==1.22.4
google-auth==1.22.1
google-cloud-vision==2.0.0
googleapis-common-protos==1.52.0
grpcio==1.32.0
html5lib==1.0.1
idna==2.8
ipaddr==2.2.0
libcst==0.3.12
lockfile==0.12.2
msgpack==0.6.2
mypy-extensions==0.4.3
packaging==20.3
pep517==0.8.2
pkg-resources==0.0.0
progress==1.5
proto-plus==1.10.0
protobuf==3.13.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyparsing==2.4.6
pytoml==0.1.21
pytz==2020.1
PyYAML==5.3.1
requests==2.22.0
retrying==1.3.3
rsa==4.6
six==1.14.0
typing-extensions==3.7.4.3
typing-inspect==0.6.0
urllib3==1.25.8
webencodings==0.5.1
Any Idea?