Find answers from the community

Updated 10 months ago

0.10.x

from https://docs.llamaindex.ai/en/stable/getting_started/starter_example.html
Plain Text
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)

cannot import, so changed to
Plain Text
from llama_index.core.indices import VectorStoreIndex
from llama_index.core.readers import SimpleDirectoryReader

content_file ="myfile"

documents = SimpleDirectoryReader(content_file).load_data()
index = VectorStoreIndex.from_documents(documents)

got runtime error
Plain Text
----> 1 from llama_index.core.indices import VectorStoreIndex
...
......./llama_index/core/indices/composability/graph.py:5
      1 """Composability graphs."""
      3 from typing import Any, Dict, List, Optional, Sequence, Type, cast
...
----> 6 from llama_index.core.llms import ChatMessage, MessageRole
      7 from llama_index.core.utils import get_tokenizer
     10 class TokenCounter:

ImportError: cannot import name 'ChatMessage' from 'llama_index.core.llms' (unknown location)
L
j
5 comments
Start with a completely fresh venv
Is my recommendation
Any remnants of the previous install will cause the issues you are seeing
For example, I would start by doing

Plain Text
python -m venv venv
source venv/bin/activate
pip install llama-index
It worked after remove and reinstall poetry env, thank you so much!
Add a reply
Sign up and join the conversation on Discord