admin管理员组

文章数量:1302266

I'm encountering an ImportError after upgrading the google-generativeai library. The error is: ImportError: cannot import name 'get_default_text_client' from 'google.generativeai.client' (/path/to/my/site-packages/google/generativeai/client.py) # Replace with your actual path!

I'm using Python [3.10] and installed the library using pip install --upgrade google-generativeai.

Here's a minimal code example that reproduces the error: Python

import os from google.generativeai import text

os.environ["GOOGLE_API_KEY"] = "xyz"

I'm not sure what's causing this issue. Any help would be greatly appreciated!

I have tried the following:

  • Upgrading google-generativeai using pip install --upgrade google-generativeai.
  • Uninstalling and reinstalling google-generativeai: pip uninstall google-generativeai followed by pip install google-generativeai.
  • Restarting my Jupyter kernel/Python interpreter.

I'm encountering an ImportError after upgrading the google-generativeai library. The error is: ImportError: cannot import name 'get_default_text_client' from 'google.generativeai.client' (/path/to/my/site-packages/google/generativeai/client.py) # Replace with your actual path!

I'm using Python [3.10] and installed the library using pip install --upgrade google-generativeai.

Here's a minimal code example that reproduces the error: Python

import os from google.generativeai import text

os.environ["GOOGLE_API_KEY"] = "xyz"

I'm not sure what's causing this issue. Any help would be greatly appreciated!

I have tried the following:

  • Upgrading google-generativeai using pip install --upgrade google-generativeai.
  • Uninstalling and reinstalling google-generativeai: pip uninstall google-generativeai followed by pip install google-generativeai.
  • Restarting my Jupyter kernel/Python interpreter.
Share asked Feb 11 at 8:33 Umesh KrishnamurthyUmesh Krishnamurthy 111 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 0

get_default_text_client is no longer available after version 0.7.2. On this version it's on line 347 of client.py. From version 0.7.3 on it's not longer in client.py.

If you really want to use it and don't want to work around it I'd suggest downgrading back to v0.7.2

The text part of the SDK was for the PaLM API. As Jesper pointed out, it's been removed from the SDK. Downgrading won't help though, because the API endpoints are no longer running either.

Consider migrating to the new google-genai package that was built for Gemini 2.0 & supports both the natural Gemini API as well as Vertex.

本文标签: