google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.62k stars 322 forks source link

Couldn't build proto file into descriptor pool #585

Closed shirsakm closed 1 week ago

shirsakm commented 1 month ago

Description of the bug:

I encounter the error "TypeError: Couldn't build proto file into descriptor pool: duplicate symbol "'google.ai.generativelanguage.v1beta.firstlineno'", when trying to import this module.

Actual vs expected behavior:

The module should import correctly and work as in the Quickstart guide.

Any other information you'd like to share?

I am using PyCharm and the module installed is google-generativeai.

manojssmk commented 1 month ago

Hi @shirsakm

I tried to reproduce the code in the PyCharm environment, and the basic Quickstart guide is functioning correctly. Would you like to try reinstalling or upgrading the google-generativeai package?

Thanks

jschanz6 commented 1 month ago

I was able to fix the issue by downgrading from Python 3.13 to 3.12.

cytsai1008 commented 1 month ago

Same here, happened on py3.13, not happened in py3.12

Traceback (most recent call last):
<module>
    import google.generativeai
  File ".venv\Lib\site-packages\google\generativeai\__init__.py", line 45, in <module>
    from google.generativeai import caching
  File ".venv\Lib\site-packages\google\generativeai\caching.py", line 21, in <module>
    from google.generativeai import protos
  File ".venv\Lib\site-packages\google\generativeai\protos.py", line 74, in <module>
    from google.ai.generativelanguage_v1beta.types import *
  File ".venv\Lib\site-packages\google\ai\generativelanguage_v1beta\__init__.py", line 21, in <module>
    from .services.cache_service import CacheServiceAsyncClient, CacheServiceClient
  File ".venv\Lib\site-packages\google\ai\generativelanguage_v1beta\services\cache_service\__init__.py", line 16, in <module>
    from .async_client import CacheServiceAsyncClient
  File ".venv\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 ".venv\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 ".venv\Lib\site-packages\google\ai\generativelanguage_v1beta\types\__init__.py", line 47, in <module>
    from .discuss_service import (
    ...<7 lines>...
    )
  File ".venv\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 ".venv\Lib\site-packages\google\ai\generativelanguage_v1beta\types\safety.py", line 224, in <module>
    class SafetySetting(proto.Message):
    ...<48 lines>...
        )
  File ".venv\Lib\site-packages\proto\message.py", line 279, in __new__
    file_info.generate_file_pb(new_class=cls, fallback_salt=full_name)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv\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__'
shirsakm commented 1 month ago

I was able to fix the issue by downgrading from Python 3.13 to 3.12.

Downgrading to 3.12.6 worked for me as well.

codelion commented 1 month ago

Running into the same issue on python 3.13, downgrading to 3.12 seems to fix the problem for now.

msukanen commented 1 month ago

And I just got 3.13 installed... Oh well, back to 3.12.7 it is.

github-actions[bot] commented 3 weeks ago

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!