You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入llama_index.indices.list.retrievers模块遇ModuleNotFoundError求助

问题描述

运行以下Python代码时出现ModuleNotFoundError: No module named 'llama_index.indices.list.retrievers':

from llama_index import GPTListIndex
from llama_index.indices.list.retrievers import ListIndexLLMRetriever

documents = SimpleDirectoryReader('./data').load_data()
index = GPTListIndex.from_documents(documents, service_context=service_context)
retriever = ListIndexLLMRetriever()
....

环境信息:

  • Python版本:3.8.1 和 3.11.0
  • 已安装依赖:llama-index0.5.6、langchain0.0.148
解决建议
  • 修正导入路径:在llama-index 0.5.6版本中,ListIndexLLMRetriever的正确导入路径为llama_index.retrievers.list_retriever,修改导入语句:
    from llama_index.retrievers.list_retriever import ListIndexLLMRetriever
    
  • 核对版本对应模块结构:llama-index不同版本的模块布局差异较大,0.5.6属于旧版本,需严格遵循该版本的官方文档规范;若允许升级,建议更新至较新的稳定版本(如0.8.x及以上),新版本模块结构更清晰,兼容性更强。
  • 确保依赖安装无冲突:执行pip show llama-index确认实际安装版本为0.5.6,若存在依赖冲突,创建虚拟环境后重新安装指定版本:
    pip uninstall llama-index langchain -y
    pip install llama-index==0.5.6 langchain==0.0.148
    

内容的提问来源于stack exchange,提问作者chi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 09:37:10