简体   繁体   中英

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 . The problem is that I am getting this error when trying to include a reference to vision from google.cloud module.

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:

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.

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

This link might provide some assistance:

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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