tryflyhi
tryflyhi

Reputation: 1

google-generativeai installed yet I get error: No module named 'google'

I am running this simple Python script;

# Install from PyPI.

# pip install -U google-generativeai

# Import the SDK and configure your API key
import os
import google.generativeai as genai

genai.configure(api_key="MY_GOOGLE_API_KEY")

# Create a model and run a prompt.

model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content("The opposite of hot is")
print(response.text)

With Python3.8, I get this error:

model = genai.GenerativeModel('gemini-1.5-flash')
AttributeError: module 'google.generativeai' has no attribute 'GenerativeModel'

Then I tried searching the Internet and found a clue somewhere to installed latest version of Python. So I installed Python3.12.4 but with Python3.12.4 I get this error:

import google.generativeai as genai
ModuleNotFoundError: No module named 'google'

Also see that:

$ pip list | grep google

google-ai-generativelanguage  0.1.0
google-api-core               2.19.1
google-api-python-client      2.136.0
google-auth                   2.30.0
google-auth-httplib2          0.2.0
google-auth-oauthlib          1.2.0
google-cloud-aiplatform       1.57.0
google-cloud-bigquery         3.25.0
google-cloud-core             2.4.1
google-cloud-resource-manager 1.12.3
google-cloud-storage          2.17.0
google-crc32c                 1.5.0
google-generativeai           0.1.0rc1
google-resumable-media        2.7.1
googleapis-common-protos      1.63.2
grpc-google-iam-v1            0.13.1

I think there is some problem that associated with the python version that I am unable to figure out.

Upvotes: 0

Views: 841

Answers (0)

Related Questions