Sardar Raheem
Sardar Raheem

Reputation: 23

ModuleNotFoundError: No module named 'google' while using google-cloud-vision api

i ran the following code

import io
import os
# Imports the Google Cloud client library
from google.cloud import vision

# Instantiates a client
client = vision.ImageAnnotatorClient()

# The name of the image file to annotate
file_name = os.path.abspath('resources/wakeupcat.jpg')

# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
    content = image_file.read()

image = vision.Image(content=content)

# Performs label detection on the image file
response = client.label_detection(image=image)
labels = response.label_annotations

print('Labels:')
for label in labels:
    print(label.description)

the error i get is the following

Traceback (most recent call last):
  File "F:\coding\pythonfolder\main.py", line 4, in <module>
    from google.cloud import vision
ModuleNotFoundError: No module named 'google'

the library is installed is the following

pip install google-cloud-vision

I am fairly new to the google vision api so maybe there's some point I am missing kindly let me know what the issue is, I tried pip install --upgrade google-cloud-vision as well but does not seems to work my python version is Python 3.10.0 kindly let me know if there's any issue or missing information in my question thank you!!

Upvotes: 1

Views: 1897

Answers (1)

Marco Frag Delle Monache
Marco Frag Delle Monache

Reputation: 1458

I'm pretty sure you messed up with the venv, since it worked fine for me. Try using PyCharm (if you don't already do) and setup a venv, or install virtualenv and launch these commands inside your project folder:

virtualenv venv
source venv/bin/activate
pip install google-cloud-vision
python your_file.py
deactivate

Last one is to properly exit the venv

Upvotes: 1

Related Questions