You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/base/base_retriever.py", line 30, in
from llama_index.core.service_context import ServiceContext
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/service_context.py", line 11, in
from llama_index.core.indices.prompt_helper import PromptHelper
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/init.py", line 4, in
from llama_index.core.indices.composability.graph import ComposableGraph
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/composability/init.py", line 4, in
from llama_index.core.indices.composability.graph import ComposableGraph
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/composability/graph.py", line 7, in
from llama_index.core.indices.base import BaseIndex
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/base.py", line 8, in
from llama_index.core.base.base_retriever import BaseRetriever
ImportError: cannot import name 'BaseRetriever' from partially initialized module 'llama_index.core.base.base_retriever' (most likely due to a circular import) (/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/base/base_retriever.py)
Version
0.10.34
Steps to Reproduce
from llama_index.core.base.base_retriever import BaseRetriever
To address the ImportError due to a circular import involving BaseRetriever, you can try the following strategies:
Refactor Your Code: Aim to eliminate the circular dependency by reorganizing your modules and packages.
Lazy Import Inside Functions: Move the BaseRetriever import statement inside the function or method that requires it, delaying the import until necessary.
Consolidate Imports: If feasible, combine related classes and functions into a single module to avoid circular dependencies.
Use Import Hooks: This advanced solution involves customizing Python's import system to resolve circular imports.
Import Within Type Checking Block: For type annotations, use if TYPE_CHECKING: to ensure imports are only executed by type checkers.
Use from __future__ import annotations: For Python 3.7+, this approach stores annotations as strings, avoiding circular imports due to type annotations.
Additionally, a similar issue was resolved by uninstalling any existing installations of llama-index, creating a new virtual environment, and reinstalling llama-index with specific pip flags. Follow these steps:
pip uninstall llama-index # remove any possible global install
python -m venv venv
source venv/bin/activate
pip install llama-index --upgrade --no-cache-dir --force-reinstall
Ensure you're not using outdated paths for imports and refer to the latest documentation for correct import statements.
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
Bug Description
Traceback (most recent call last):
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/base/base_retriever.py", line 30, in
from llama_index.core.service_context import ServiceContext
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/service_context.py", line 11, in
from llama_index.core.indices.prompt_helper import PromptHelper
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/init.py", line 4, in
from llama_index.core.indices.composability.graph import ComposableGraph
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/composability/init.py", line 4, in
from llama_index.core.indices.composability.graph import ComposableGraph
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/composability/graph.py", line 7, in
from llama_index.core.indices.base import BaseIndex
File "/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/indices/base.py", line 8, in
from llama_index.core.base.base_retriever import BaseRetriever
ImportError: cannot import name 'BaseRetriever' from partially initialized module 'llama_index.core.base.base_retriever' (most likely due to a circular import) (/data/env/anaconda3/lib/python3.10/site-packages/llama_index/core/base/base_retriever.py)
Version
0.10.34
Steps to Reproduce
from llama_index.core.base.base_retriever import BaseRetriever
llama-hub 0.0.79.post1
llama-index 0.10.34
llama-index-agent-openai 0.1.7
llama-index-cli 0.1.12
llama-index-core 0.10.34
llama-index-embeddings-openai 0.1.9
llama-index-indices-managed-llama-cloud 0.1.6
llama-index-legacy 0.9.48
llama-index-llms-openai 0.1.16
llama-index-multi-modal-llms-openai 0.1.5
llama-index-program-openai 0.1.6
llama-index-question-gen-openai 0.1.3
llama-index-readers-file 0.1.19
llama-index-readers-llama-parse 0.1.4
llama-parse 0.4.2
llamaindex-py-client 0.1.19
Relevant Logs/Tracbacks
No response
The text was updated successfully, but these errors were encountered: