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.19k stars 227 forks source link

[Bugs] protobuf bugs when importing generativeai module. #360

Closed Luodian closed 2 weeks ago

Luodian commented 1 month ago

Description of the bug:

import google.generativeai as genai

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/generativeai/__init__.py", line 45, in <module>
from google.generativeai import types
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/generativeai/types/__init__.py", line 17, in <module>
from google.generativeai.types.citation_types import *
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/generativeai/types/citation_types.py", line 20, in <module>
from google.ai import generativelanguage as glm
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/ai/generativelanguage/__init__.py", line 21, in <module>
from google.ai.generativelanguage_v1beta.services.discuss_service.async_client import (
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/__init__.py", line 21, in <module>
from .services.discuss_service import DiscussServiceAsyncClient, DiscussServiceClient
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/services/discuss_service/__init__.py", line 16, in <module>
from .async_client import DiscussServiceAsyncClient
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/services/discuss_service/async_client.py", line 48, in <module>
from google.ai.generativelanguage_v1beta.types import discuss_service, safety
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/types/__init__.py", line 16, in <module>
from .citation import CitationMetadata, CitationSource
File "/home/tiger/miniconda3/envs/gemini/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/types/citation.py", line 22, in <module>
__protobuf__ = proto.module(
AttributeError: module 'proto' has no attribute 'module'

Actual vs expected behavior:

No response

Any other information you'd like to share?

I could make this work on Mac and another instance. But can not make it work on our development environment. I am not sure if this is about the package version issues?

There are more environment info:

aiofiles==22.1.0
aiosqlite==0.20.0
annotated-types==0.7.0
anyio==4.3.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
attrs==23.1.0
Babel==2.15.0
beautifulsoup4==4.12.3
bidict==0.23.1
bleach==6.1.0
byted-remote-ikernel==0.4.8
byted-torch-monitor @ https://d.scm.byted.org/api/v2/download/lab.pytorch.torch_monitor_1.0.0.6.tar.gz#sha256=333bc7b5f093bb449cad019a5351702f7497fc7b5e4a3f1c82f6567e607c3e1e
byted-wandb==0.13.72
bytedance-context==0.7.1
bytedance-metrics==0.5.1
bytedance.modelhub==0.0.64
bytedance.servicediscovery==0.1.2
bytedbackgrounds==0.0.6
byteddatabus==1.0.6
byteddps==0.1.2
bytedenv==0.6.2
bytedlogger==0.15.1
bytedmemfd==0.2
bytedmetrics==0.10.2
bytedpymongo==2.0.5
bytedrh2==1.18.7a2
bytedservicediscovery==0.17.4
bytedtcc==1.4.2
bytedtos==1.1.16
bytedtrace==0.3.0
bytedztijwthelper==0.0.22
bytedztispiffe==0.0.14
cachetools==5.3.3
certifi==2024.2.2
cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
comm==0.2.2
crcmod==1.7
cryptography==42.0.7
debugpy==1.8.1
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.14
distlib==0.3.8
dnspython==2.6.1
docker-pycreds==0.4.0
entrypoints==0.4
exceptiongroup==1.2.1
executing==2.0.1
fastjsonschema==2.19.1
filelock==3.14.0
fqdn==1.5.1
gitdb==4.0.11
GitPython==3.1.43
google-ai-generativelanguage==0.6.3
google-api-core==2.19.0
google-api-python-client==2.129.0
google-auth==2.29.0
google-auth-httplib2==0.2.0
google-generativeai==0.5.3
googleapis-common-protos==1.63.0
grpcio==1.64.0
grpcio-status==1.62.2
h11==0.14.0
httplib2==0.22.0
idna==3.7
importlib_metadata==7.1.0
iniconfig==2.0.0
ipaddress==1.0.23
ipykernel==6.29.4
ipython==8.18.1
ipython-genutils==0.2.0
ipywidgets==8.1.2
isoduration==20.11.0
jedi==0.19.1
json5==0.9.25
jsonpointer==2.4
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter==1.0.0
jupyter-client==7.0.0
jupyter-console==6.6.3
jupyter-events==0.10.0
jupyter-ydoc==0.2.5
jupyter_core==5.7.2
jupyter_server==2.14.0
jupyter_server_fileid==0.9.2
jupyter_server_terminals==0.5.3
jupyter_server_ydoc==0.8.0
jupyterlab==3.6.4
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.1
jupyterlab_widgets==3.0.10
lmms_eval==0.1.1
matplotlib-inline==0.1.7
mistune==3.0.2
msgpack==1.0.8
nbclassic==1.0.0
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==6.5.7
notebook_shim==0.2.4
overrides==7.7.0
packaging==24.0
pandocfilters==1.5.1
parso==0.8.4
pathlib2==2.3.7.post1
pathtools==0.1.2
pexpect==4.8.0
platformdirs==4.2.2
pluggy==1.5.0
ply==3.11
prometheus_client==0.20.0
promise==2.3
prompt-toolkit==3.0.43
proto-plus==1.23.0
protobuf==4.24.3
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
py==1.11.0
py-spy==0.3.14
pyarrow==16.1.0
pyasn1==0.6.0
pyasn1_modules==0.4.0
pycparser==2.22
pycryptodomex==3.20.0
pydantic==2.7.1
pydantic_core==2.18.2
Pygments==2.18.0
PyJWT==2.8.0
pyOpenSSL==24.1.0
pyparsing==3.1.2
pytest==6.2.5
python-consul==1.1.0
python-dateutil==2.9.0.post0
python-engineio==4.9.1
python-etcd==0.4.5
python-json-logger==2.0.7
python-socketio==5.11.2
PyYAML==6.0.1
pyzmq==26.0.3
qtconsole==5.5.2
QtPy==2.4.1
referencing==0.35.1
requests==2.32.2
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.18.1
rsa==4.9
schedule==1.2.1
Send2Trash==1.8.3
sentry-sdk==2.3.0
setproctitle==1.3.3
shortuuid==1.0.13
simple-websocket==1.0.0
smmap==5.0.1
sniffio==1.3.1
soupsieve==2.5
stack-data==0.6.3
terminado==0.18.1
thriftpy2==0.5.0
tinycss2==1.3.0
toml==0.10.2
tomli==2.0.1
tornado==6.4
tox==3.28.0
tqdm==4.66.4
traitlets==5.14.3
types-python-dateutil==2.9.0.20240316
typing_extensions==4.11.0
uri-template==1.3.0
uritemplate==4.1.1
urllib3==2.2.1
virtualenv==20.26.2
wandb==0.17.0
watchdog==4.0.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.8.0
widgetsnbextension==4.0.10
wrapt==1.16.0
wsproto==1.2.0
y-py==0.6.2
ypy-websocket==0.8.4
zipp==3.18.2
singhniraj08 commented 1 month ago

@Luodian, I am unable to replicate this error on our end. Can you please let us know which package version you are working with and try out with the latest release? I tried working with 0.5.4 release and the module upload works without any issues. Ref: image

github-actions[bot] commented 4 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 2 weeks ago

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