yihong0618/tg_bot_collections

google.auth.exceptions.DefaultCredentialsError的问题

lopezycj opened this issue · 6 comments

Traceback (most recent call last):
File "F:\my\tg_bot_collections2\handlers_init_.py", line 53, in wrapper
return handler(message, *args, **kwargs)
File "F:\my\tg_bot_collections2\handlers\gemini.py", line 167, in gemini_handler
player.send_message(m)
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\generativeai\generative_models.py", line 367, in send_message
response = self.model.generate_content(
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\generativeai\generative_models.py", line 241, in generate_content
self._client = client.get_default_generative_client()
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\generativeai\client.py", line 230, in get_default_generative_client
return _client_manager.get_default_client("generative")
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\generativeai\client.py", line 161, in get_default_client
client = self.make_client(name)
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\generativeai\client.py", line 121, in make_client
client = cls(**self.client_config)
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\client.py", line 433, in init
self._transport = Transport(
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\transports\grpc.py", line 150, in init
super().init(
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\transports\base.py", line 98, in init
credentials, _ = google.auth.default(
File "F:\my\tg_bot_collections2.venv\lib\site-packages\google\auth_default.py", line 691, in default
raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.

首先确定你的 terminal 能用 gemini 香港的梯子不行的,得用美国或者日本的

我是用美国的VPS

我用这个例子就可以正常用gemini的https://github.com/abersheeran/telegram-bot

@lopezycj 感谢我确认下

pip install google-generativeai==0.3.1

还是不行,一样的错误,我这个破VPS,安装gcloud都没成功过。