llama_index: [Bug]: import error generated by SimpleDirectoryReader()

Bug Description

After upgrading to 0.10.4 SimpleDirectoryReader() generates an import error as it cannot find “DocxReader” in “llama_index.readers.file”.

image

Version

0.10.3

Steps to Reproduce

import openai import os import llama_index.core.readers as readers

openai.api_key = os.environ[‘OPENAI_API_KEY’]

source_dir_html = ‘/home/wb200/data/llm/doc/MLX_AU/test/html/’

reader = readers.SimpleDirectoryReader(input_dir=source_dir_html) documents = reader.load_data()

Relevant Logs/Tracbacks

Traceback (most recent call last):
  File "/home/wb200/anaconda3/envs/llm/lib/python3.11/site-packages/llama_index/core/readers/file/base.py", line 21, in _try_loading_included_file_formats
    from llama_index.readers.file import (
ImportError: cannot import name 'DocxReader' from 'llama_index.readers.file' (unknown location)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wb200/python/LLM/test.py", line 13, in <module>
    documents = reader.load_data()
                ^^^^^^^^^^^^^^^^^^
  File "/home/wb200/anaconda3/envs/llm/lib/python3.11/site-packages/llama_index/core/readers/file/base.py", line 396, in load_data
    SimpleDirectoryReader.load_file(
  File "/home/wb200/anaconda3/envs/llm/lib/python3.11/site-packages/llama_index/core/readers/file/base.py", line 303, in load_file
    default_file_reader_cls = SimpleDirectoryReader.supported_suffix_fn()
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wb200/anaconda3/envs/llm/lib/python3.11/site-packages/llama_index/core/readers/file/base.py", line 35, in _try_loading_included_file_formats
    raise ImportError("`llama-index-readers-file` package not found")
ImportError: `llama-index-readers-file` package not found

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (4 by maintainers)

Most upvoted comments

@datascientist

pip install -U llama-index-readers-file

I’m surprised you had this issue, unless you only installed core

@damsdams1995 I fixed the issue with this:

pip3 uninstall llama-index
pip3 install llama-index --upgrade --no-cache-dir --force-reinstall

Thanks, this solved the issue without creating a new environment.

@damsdams1995 I fixed the issue with this:

pip3 uninstall llama-index
pip3 install llama-index --upgrade --no-cache-dir --force-reinstall

@jiyzhang please create a fresh venv and try again

I created a new env with conda and didn’t encounter this issue again. thanks

I have already downloaded the llama-index-readers-file, same issue 😃

On Wed, 21 Feb 2024 at 15:58, Manjunath Janardhan @.***> wrote:

@datascientist https://github.com/datascientist

pip install -U llama-index-readers-file

I’m surprised you had this issue, unless you only installed core

Thanks! This worked for me as well!

— Reply to this email directly, view it on GitHub https://github.com/run-llama/llama_index/issues/10773#issuecomment-1956839683, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGGLRBJHYPTA5BVYYDEK6JLYUYDQDAVCNFSM6AAAAABDLP4T5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWHAZTSNRYGM . You are receiving this because you commented.Message ID: @.***>

@jiyzhang please create a fresh venv and try again

I created a new env with conda and didn’t encounter this issue again. thanks

Same here

@wb200 can you try with a fresh venv?

For example, I do

python -m venv venv
source venv/bin/activate
pip install llama-index

And then it works for me

Haven’t tried that yet as I’m used to conda env system. And it doesn’t seem to work there.