|
62 | 62 | except importlib_metadata.PackageNotFoundError: |
63 | 63 | _pytesseract_available = False |
64 | 64 |
|
65 | | -_gcv_available = importlib.util.find_spec("google.cloud.vision") is not None |
66 | 65 | try: |
67 | | - _gcv_version = importlib_metadata.version( |
68 | | - "google-cloud-vision" |
69 | | - ) # This is slightly different |
70 | | - logger.debug(f"Google Cloud Vision Utils version {_gcv_version} available.") |
71 | | -except importlib_metadata.PackageNotFoundError: |
| 66 | + _gcv_available = importlib.util.find_spec("google.cloud.vision") is not None |
| 67 | + try: |
| 68 | + _gcv_version = importlib_metadata.version( |
| 69 | + "google-cloud-vision" |
| 70 | + ) # This is slightly different |
| 71 | + logger.debug(f"Google Cloud Vision Utils version {_gcv_version} available.") |
| 72 | + except importlib_metadata.PackageNotFoundError: |
| 73 | + _gcv_available = False |
| 74 | +except ModuleNotFoundError: |
72 | 75 | _gcv_available = False |
73 | 76 |
|
74 | 77 |
|
@@ -142,7 +145,7 @@ def is_gcv_available(): |
142 | 145 | ("torch", (is_torch_available, PYTORCH_IMPORT_ERROR)), |
143 | 146 | ("detectron2", (is_detectron2_available, DETECTRON2_IMPORT_ERROR)), |
144 | 147 | ("paddle", (is_paddle_available, PADDLE_IMPORT_ERROR)), |
145 | | - ("effdet", (is_effdet_available, )), |
| 148 | + ("effdet", (is_effdet_available, EFFDET_IMPORT_ERROR)), |
146 | 149 | ("pytesseract", (is_pytesseract_available, PYTESSERACT_IMPORT_ERROR)), |
147 | 150 | ("google-cloud-vision", (is_gcv_available, GCV_IMPORT_ERROR)), |
148 | 151 | ] |
|
0 commit comments