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

使用llama-index时遇ImportError:无法导入GPTSimpleVectorIndex

llama-index 导入 GPTSimpleVectorIndex 报错解决方案

问题原因

最新版本的llama-index已移除GPTSimpleVectorIndex类,将其重命名为GPTVectorStoreIndex,直接导入旧类名会触发ImportError。

修复步骤

  • 检查运行的代码文件,确保导入语句使用新类名:
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext

你提供的源码中已经使用了正确的GPTVectorStoreIndex,大概率是运行了未更新的旧代码文件。

  • 若需临时兼容旧代码,可通过别名过渡(不推荐长期使用):
from llama_index import GPTVectorStoreIndex as GPTSimpleVectorIndex

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 20:21:57