I am trying to create a script in Jupyter
for testing Google Gemini AI model.
import google.generativeai as genai
import os
# genai.configure(api_key="API Key")
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content('Please summarise this document: ...')
print(response.text)
I'm getting this error:
AttributeError
Traceback (most recent call last)
Input In [2], in <cell line: 6>()
2 import os
4 # genai.configure(api_key=os.environ['API_KEY'])
----> 6 model = genai.GenerativeModel('gemini-pro')
7 response = model.generate_content('Please summarise this document: ...')
9 print(response.text)
AttributeError: module 'google.generativeai' has no attribute 'GenerativeModel'
I tried:
python3.11 -m pip install google-generativeai
GenerativeModel
existed in my installed package source code but it didn't help.Python and package versions:
The class should exist since v0.3.0 (https://github.com/google-gemini/generative-ai-python/commit/098854379496247617ef7fea882694022fca171d)
You must be using an older version of the SDK.
There are two likely causes:
%pip install
magic to install packages.I'm having the same issue as you, a fix that you may or maynot be able to implement is downgrading your python version back to 3.10 in which gemini seems to be working without any issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With