且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Python从Raspberry Pi访问Google Cloud Vision API?

更新时间:2022-11-26 16:10:44

经过一些调查,我想说这个问题与错误/未更新的依赖关系的使用有关,而不是与Cloud Vision API库本身有关.

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.

根据您收到的错误消息,似乎没有找到 requests 库,并且在运行后也无法导入 DependencyWarning sudo pip3 install --upgrade requests 它说该库已经是最新的了.因此,我怀疑安装本身是否有问题.

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.

我建议您执行以下步骤(如有必要,请使用 pip3 ):

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

如果这些都不起作用,则可能是Python 3本身存在问题.您可以使用Python 2进行测试,并确认该版本是否也会失败吗?

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?