简体   繁体   English

无法在 python 脚本中导入 google.cloud 模块

[英]Can not import google.cloud module in python script

I am following this article trying to make my Python script read labels related to an image using Google Cloud Vision API .我正在关注这篇文章,试图让我的 Python 脚本使用Google Cloud Vision API读取与图像相关的标签。 The problem is that I am getting this error when trying to include a reference to vision from google.cloud module.问题是我在尝试从 google.cloud 模块中包含对视觉的引用时遇到此错误。

import io
from google.cloud import vision
from google.cloud.vision import types

The error that I am getting says:我得到的错误说:

ImportError: No module named 'google.cloud'

This is weird because when I do:这很奇怪,因为当我这样做时:

$ pip show google-cloud

I can see it is there and its files are located at:我可以看到它在那里,它的文件位于:

/usr/local/lib/python2.7/dist-packages/google_cloud-0.34.0.dist-info/*

Except for that, when I do pip freeze in my working folder I can see them both that I need available:除此之外,当我在我的工作文件夹中执行pip freeze 时,我可以看到它们都是我需要的:

google-cloud==0.34.0
google-cloud-vision==0.33.0

I am now wondering what could be the reason for not being able to see include this module in my Python script.我现在想知道在我的 Python 脚本中看不到包含这个模块的原因可能是什么。

不推荐使用google-cloud软件包,您应该卸载它并安装google-cloud-vision

This link might provide some assistance:此链接可能会提供一些帮助:

https://cloud.google.com/python/ https://cloud.google.com/python/

Edited已编辑

upon looking into it further, I was able to do the following:进一步研究后,我能够执行以下操作:

pip install google-cloud-vision

and import everything with:并导入所有内容:

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

Maybe try uninstalling the package through pip and reinstalling it with the above?也许尝试通过 pip 卸载软件包并使用上述方法重新安装?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM