Layout-Parser / layout-parser

A Unified Toolkit for Deep Learning Based Document Image Analysis
https://layout-parser.github.io/
Apache License 2.0
4.78k stars 459 forks source link

instantiating lp.GCVAgent.with_credential returns module 'google.cloud.vision' has no attribute 'types' #12

Closed apoorvalal closed 3 years ago

apoorvalal commented 3 years ago

Thanks for putting this amazing looking library together. I tried to work through the Table example in the documentation and get a no attribute 'types' error when I run this line

ocr_agent = lp.GCVAgent.with_credential("/home/alal/keys/sandbox-7f8884d01b79.json", 
                                        languages = ['en'])
>module 'google.cloud.vision' has no attribute 'types'

I am running lp in a conda environment on ubuntu 18.04., have installed google.cloud.vision, and have enabled it on console.cloud.google.com and have GOOGLE_APPLICATION_CREDENTIALS in my path.

I've also verified that I can run the document-text tutorial in my conda environment https://cloud.google.com/vision/docs/fulltext-annotations.

lolipopshock commented 3 years ago

Ahh that should be a problem related to the google.cloud.vision APIs. Could you share the exact version of the API via pip show google-cloud-vision?

apoorvalal commented 3 years ago

Thanks for the prompt response. I have google-cloud-vision 2.3.0.

apoorvalal commented 3 years ago

Ah, I just looked into dependencies and realised that I need GCV 1.0. Rolled back the version and it worked fine. I got the dependencies wrong. I'm not sure why

# Install the ocr components when necessary
pip install layoutparser[ocr]

this line didn't run for me.