Gemini API & Python newbie here, so please forgive potentially stupid question. Trying to use the Gemini API to generate images using Imagen 3 by following this tutorial: Generate images using Imagen 3 | Gemini API | Google AI for Developers. I am using a clean Python 3.13 install via PowerShell 7.4.5 on a Win11 machine. The python install includes pip, pillow, git and winget (among others). If it matters, everything was installed with PS running with admin privileges.
I am able to successfully follow the tutorial until I get to this line:
import google.generativeai as genai
That line results in the following error:
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
import google.generativeai as genai
File "C:\Program Files\Python313\Lib\site-packages\google\generativeai\__init__.py", line 45, in <module>
from google.generativeai import caching
File "C:\Program Files\Python313\Lib\site-packages\google\generativeai\caching.py", line 21, in <module>
from google.generativeai import protos
File "C:\Program Files\Python313\Lib\site-packages\google\generativeai\protos.py", line 74, in <module>
from google.ai.generativelanguage_v1beta.types import *
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\__init__.py", line 21, in <module>
from .services.cache_service import CacheServiceAsyncClient, CacheServiceClient
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\services\cache_service\__init__.py", line 16, in <module>
from .async_client import CacheServiceAsyncClient
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\services\cache_service\async_client.py", line 50, in <module>
from google.ai.generativelanguage_v1beta.services.cache_service import pagers
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\services\cache_service\pagers.py", line 41, in <module>
from google.ai.generativelanguage_v1beta.types import cache_service, cached_content
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\types\__init__.py", line 47, in <module>
from .discuss_service import (
...<7 lines>...
)
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\types\discuss_service.py", line 22, in <module>
from google.ai.generativelanguage_v1beta.types import citation, safety
File "C:\Program Files\Python313\Lib\site-packages\google\ai\generativelanguage_v1beta\types\safety.py", line 224, in <module>
class SafetySetting(proto.Message):
...<48 lines>...
)
File "C:\Program Files\Python313\Lib\site-packages\proto\message.py", line 279, in __new__
file_info.generate_file_pb(new_class=cls, fallback_salt=full_name)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python313\Lib\site-packages\proto\_file_info.py", line 104, in generate_file_pb
pool.Add(self.descriptor)
~~~~~~~~^^^^^^^^^^^^^^^^^
TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'google.ai.generativelanguage.v1beta.__firstlineno__'
Attempting to follow any subsequent steps are unsuccessful. Any suggestions regarding cause and solution greatly appreciated.