Open ddoddii opened 6 months ago
I'm having this exact issue
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[22], line 2
1 # listing all available models
----> 2 from google import generativeai
3 # for model in genai.list_models():
4 # print(model.name)
File ~/.local/lib/python3.11/site-packages/google/generativeai/__init__.py:45
41 from __future__ import annotations
43 from google.generativeai import version
---> 45 from google.generativeai import types
46 from google.generativeai.types import GenerationConfig
49 from google.generativeai.discuss import chat
File ~/.local/lib/python3.11/site-packages/google/generativeai/types/__init__.py:17
1 # -*- coding: utf-8 -*-
2 # Copyright 2023 Google LLC
3 #
(...)
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 """A collection of type definitions used throughout the library."""
---> 17 from google.generativeai.types.discuss_types import *
18 from google.generativeai.types.model_types import *
19 from google.generativeai.types.text_types import *
File ~/.local/lib/python3.11/site-packages/google/generativeai/types/discuss_types.py:22
19 from typing import Any, Dict, Union, Iterable, Optional, Tuple, List
20 from typing_extensions import TypedDict
---> 22 import google.ai.generativelanguage as glm
23 from google.generativeai import string_utils
25 from google.generativeai.types import safety_types
File ~/.local/lib/python3.11/site-packages/google/ai/generativelanguage/__init__.py:21
16 from google.ai.generativelanguage import gapic_version as package_version
18 __version__ = package_version.__version__
---> 21 from google.ai.generativelanguage_v1beta.services.discuss_service.async_client import (
22 DiscussServiceAsyncClient,
23 )
24 from google.ai.generativelanguage_v1beta.services.discuss_service.client import (
25 DiscussServiceClient,
26 )
27 from google.ai.generativelanguage_v1beta.services.generative_service.async_client import (
28 GenerativeServiceAsyncClient,
29 )
File ~/.local/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/discuss_service/__init__.py:16
1 # -*- coding: utf-8 -*-
2 # Copyright 2023 Google LLC
3 #
(...)
14 # limitations under the License.
15 #
---> 16 from .async_client import DiscussServiceAsyncClient
17 from .client import DiscussServiceClient
19 __all__ = (
20 "DiscussServiceClient",
21 "DiscussServiceAsyncClient",
22 )
File ~/.local/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/discuss_service/async_client.py:38
35 from google.auth import credentials as ga_credentials # type: ignore
36 from google.oauth2 import service_account # type: ignore
---> 38 from google.ai.generativelanguage_v1beta import gapic_version as package_version
40 try:
41 OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
File ~/.local/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/__init__.py:21
16 from google.ai.generativelanguage_v1beta import gapic_version as package_version
18 __version__ = package_version.__version__
---> 21 from .services.discuss_service import DiscussServiceAsyncClient, DiscussServiceClient
22 from .services.generative_service import (
23 GenerativeServiceAsyncClient,
24 GenerativeServiceClient,
25 )
26 from .services.model_service import ModelServiceAsyncClient, ModelServiceClient
ImportError: cannot import name 'DiscussServiceAsyncClient' from partially initialized module 'google.ai.generativelanguage_v1beta.services.discuss_service' (most likely due to a circular import) (/home/obinna/.local/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/discuss_service/__init__.py)
which version? can you show more details: the minimal reproduce code snippet
I've seen this, but don't have steps to reproduce it.
I think this had something to do with the namespace package configuration: https://github.com/google-gemini/generative-ai-python/commit/b28f2d1395d888fe149a031afbec359e1b523f8e
Does this still happen for anyone, with newer versions?
I had the exact same issue today. I was trying to run the code on a .ipynb file. What worked for me was to restart the Jupyter kernel. I guess I was getting this error after installing some packages (like grpcio) required by google-generativeai, and restarting the kernel somehow fixed the issue. Hope this can help others as well. (Python 3.12.3)
Description of the bug:
While running this python file in my local jupyter server, this error occurred.
Below is the full error.
I installed google-gnerativeai via
pip install google-generativeai
and also ranpip install -q -U google-generativeai
on my terminal.It seems to work fine on google colab(python ver 3.10), but I don't know what's the problem here. The documents says it supports python 3.9, 3.10, 3.11 pypi google-ai-generativelanguage docs
Actual vs expected behavior:
expected: It should work fine. actual : circular import error
Any other information you'd like to share?
I tried python 3.10 locally, but still same circular import error. I also made new conda environment with no additional libraries installed, but still this error occurred.
No response