Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Import Error (Vision API) 'ImportError: cannot import name 'types' from 'google.cloud.vision' #57

Closed
flo-s99 opened this issue Oct 2, 2020 · 5 comments
Assignees
Labels
api: vision Issues related to the googleapis/python-vision API. type: question Request for information or clarification. Not an issue.

Comments

@flo-s99
Copy link

flo-s99 commented Oct 2, 2020

I'm trying to run the Vision API on my Mac (Text Editor VSCode) but I always get the same Error: ImportError: cannot import name 'types' from 'google.cloud.vision' (Full Screenshot attached)

I tried the following fixes:

  • I ran several versions of python in a venv (it was active)
  • I installed several versions of the google-cloud-vision (v0, 1.0.0, 2.0.0)
  • I checked several times if my venv was contamined by running this code

mkdir test cd test python3 -m venv venv source venv/bin/activate pip install google-cloud-vision python3 -c "from google.cloud import vision; print(vision.__name__)" google.cloud.vision_

I will also post my installed packages
aiohttp==3.6.2 async-timeout==3.0.1 attrs==20.2.0 cachetools==4.1.1 certifi==2020.6.20 chardet==3.0.4 google-api-core==1.22.2 google-auth==1.22.0 google-cloud-vision==2.0.0 googleapis-common-protos==1.52.0 grpcio==1.32.0 idna==2.10 libcst==0.3.12 multidict==4.7.6 mypy-extensions==0.4.3 proto-plus==1.10.0 protobuf==3.13.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 pytz==2020.1 PyYAML==5.3.1 requests==2.24.0 rsa==4.6 six==1.15.0 typing-extensions==3.7.4.3 typing-inspect==0.6.0 urllib3==1.25.10 yarl==1.6.0

I will appreciate any help.

Bildschirmfoto 2020-10-02 um 11 39 56

@busunkim96 busunkim96 transferred this issue from googleapis/google-cloud-python Oct 2, 2020
@product-auto-label product-auto-label bot added the api: vision Issues related to the googleapis/python-vision API. label Oct 2, 2020
@busunkim96
Copy link
Contributor

Per the Migration Guide, the enums and types modules have been removed. You can access all the types under vision directly.

from google.cloud import vision_v1

request = vision_v1.GetProductSetRequest(name="name")

@busunkim96 busunkim96 self-assigned this Oct 2, 2020
@busunkim96 busunkim96 added the type: question Request for information or clarification. Not an issue. label Oct 2, 2020
@flo-s99 flo-s99 closed this as completed Oct 3, 2020
@santma
Copy link

santma commented Nov 13, 2020

Per the Migration Guide, the enums and types modules have been removed. You can access all the types under vision directly.

from google.cloud import vision_v1

request = vision_v1.GetProductSetRequest(name="name")

does this also go for google.cloud.language ?

@busunkim96
Copy link
Contributor

@santma Yep! Most of the libraries went through a similar change. I believe that code will work for language, but you can also reference that library's Guide.

@di
Copy link
Member

di commented Nov 18, 2020

I think some of the docs still need updated, e.g. this line seems to have been missed in #68.

@me-suzy
Copy link

me-suzy commented Jun 18, 2023

#pip install google-cloud-vision

import os
from google.cloud import vision
from google.cloud.vision_v1 import types

# Set up the Google Cloud Vision client
client = vision.ImageAnnotatorClient()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: vision Issues related to the googleapis/python-vision API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants