I ran into this problem when I was trying to import the following libraries and it is giving the error "ImportError: cannot import name 'VectorStoreIndex' from 'llama_index' (unknown location)"
I ran this exact same code in the morning and it worked perfectly.
I did !pip install llama_index
from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext
from llama_index.llms import HuggingFaceLLM
from llama_index.prompts.prompts import SimpleInputPrompt
I tried commenting out first line and faced same issue for HuggingFaceLLM module Same issue for SimpleInputPrompt, got error "ModuleNotFoundError: No module named 'llama_index.prompts'"
First I faced the problem in a sagemaker notebook so I thought the issue was with the sagemaker notebook so I spun up a clean new notebook and I got the same error. So, I tried the code in my local Jypiter notebook, google collab notebook, sagemaker studiolab notebook and I got the same error.
from llama_index.core import VectorStoreIndex
will throw aTypeError: Plain typing.TypeAlias is not valid as type argument
. In that case use legacy module instead of core-from llama_index.legacy import VectorStoreIndex
. – Hog