Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'SimpleDirectoryReader' from 'llama_index' (unknown location)

Tags:

llama-index

from llama_index import SimpleDirectoryReader, ServiceContext, VectorStoreIndex
from llama_index.llms import OpenAI

Upon trying the above imports I get the following error:

ImportError: cannot import name 'SimpleDirectoryReader' from 'llama_index' (unknown location)

Along with:

ModuleNotFoundError: No module named 'llama_index.llms'

I have tried importing llama index via both pip and directly from github.

I am using 0.7.18 version of llama-index.

like image 582
abstract Avatar asked Jan 26 '26 15:01

abstract


2 Answers

If you're encountering import errors with llama_index, such as:

ImportError: cannot import name 'SimpleDirectoryReader' from 'llama_index' (unknown location) ModuleNotFoundError: No module named 'llama_index.llms' And you're using version 0.7.18 of llama-index, the solution lies in the recent updates to the library. The structure of imports has been modified, which requires adjusting how you import specific components.

To resolve these import errors, you should update your import statements to reflect the new structure as per the latest documentation. For instance:

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
like image 185
Raoof Naushad Avatar answered Jan 29 '26 13:01

Raoof Naushad


It was deprecated. Use as follows:

from llama_index.core import SimpleDirectoryReader, ServiceContext, VectorStoreIndex
like image 26
Aiden Avatar answered Jan 29 '26 14:01

Aiden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!