Reputation: 1029
I am trying to access Google Cloud Vision API to perform OCR from Raspberry Pi 3. I have followed the instructions in the given link -
https://cloud.google.com/vision/docs/libraries#client-libraries-install-python
However, when I try to import the library using the following code, I an error as shown below -
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
I get this error. I have navigated inside the directory - /usr/local/lib/python3.4/dist-packages/google/auth/transport/
and I have found the requests.py
file. I have also installed the Python requests
module. In spite of that I get the following error.
/usr/local/lib/python3.4/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.9.1) or chardet (2.3.0) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/google/auth/transport/requests.py", line 23, in <module>
import requests
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 90, in <module>
from urllib3.exceptions import DependencyWarning
ImportError: cannot import name 'DependencyWarning'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "gc.py", line 7, in <module>
from google.cloud import vision
File "/usr/local/lib/python3.4/dist-packages/google/cloud/vision.py", line 20, in <module>
from google.cloud.vision_v1 import enums
File "/usr/local/lib/python3.4/dist-packages/google/cloud/vision_v1/__init__.py", line 22, in <module>
from google.cloud.vision_v1.gapic import image_annotator_client as iac
File "/usr/local/lib/python3.4/dist-packages/google/cloud/vision_v1/gapic/image_annotator_client.py", line 18, in <module>
import google.api_core.gapic_v1.client_info
File "/home/pi/.local/lib/python3.4/site-packages/google/api_core/gapic_v1/__init__.py", line 17, in <module>
from google.api_core.gapic_v1 import method
File "/home/pi/.local/lib/python3.4/site-packages/google/api_core/gapic_v1/method.py", line 22, in <module>
from google.api_core import grpc_helpers
File "/home/pi/.local/lib/python3.4/site-packages/google/api_core/grpc_helpers.py", line 27, in <module>
import google.auth.transport.requests
File "/usr/local/lib/python3.4/dist-packages/google/auth/transport/requests.py", line 31, in <module>
caught_exc,
File "<string>", line 3, in raise_from
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
Please help.
EDIT -
I tried sudo pip3 install --upgrade requests
and got the following status -
Requirement already up-to-date: requests in /usr/local/lib/python3.4/dist-packages
Cleaning up...
Upvotes: 1
Views: 884
Reputation: 8178
After some investigation, I would say this issue is more related to the usage of wrong/not updated dependencies rather than with the Cloud Vision API libraries themselves.
According to the error message you are getting, it looks like the requests
library is not found, and also DependencyWarning
cannot be imported, however, after running sudo pip3 install --upgrade requests
it says that the library is already up-to-date. Therefore, I suspect that either there is an issue with the installation itself.
I would suggest that you do the following steps (use pip3
if necessary):
# Upgrade pip
$ sudo pip install --upgrade pip
# Uninstall then re-install requests
$ sudo pip uninstall requests
$ sudo pip install --upgrade requests
# Upgrade the urllib3 and chardet libraries mentioned in the warning
$ sudo pip install --upgrade urllib3
$ sudo pip install --upgrade chardet
If none of this works, it may be that the issue is with Python 3 itself. Can you test the same using Python 2 and confirm whether it fails with that version too?
Upvotes: 1