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”.
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 5 months ago
- Reactions: 1
- Comments: 17 (3 by maintainers)
@datascientist
pip install -U llama-index-readers-fileI’m surprised you had this issue, unless you only installed core
I created a new env with conda and didn’t encounter this issue again. thanks
🤖
Based on the error message you provided, it seems like the
DocxReaderclass cannot be found in thellama_index.readers.filemodule. This could be due to a change in the import structure in the LlamaIndex v0.10.4 update.The
DocxReaderclass might have been moved to a different module or renamed. You suggested that the import should be written as “from llama_index.readers.file.docs import DocxReader”. This could be correct if theDocxReaderclass was moved to thedocsmodule in thellama_index.readers.filepackage.To confirm this, you can check the source code of the
llama_index.readers.filepackage in the LlamaIndex repository. If theDocxReaderclass is indeed in thedocsmodule, you should update your import statement accordingly.However, if you can’t find the
DocxReaderclass in thedocsmodule or anywhere else in thellama_index.readers.filepackage, it’s possible that the class was removed or renamed in the v0.10.4 update. In this case, you should check the release notes or the migration guide for v0.10.4 to see if there are any notes about changes to theDocxReaderclass.If you’re still having trouble, please provide more information about your environment (e.g., Python version, operating system) and any other relevant details about your setup. This will help me better understand the issue and provide a more accurate solution.
Sources
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
I have already downloaded the llama-index-readers-file, same issue 😃
On Wed, 21 Feb 2024 at 15:58, Manjunath Janardhan @.***> wrote:
Same here
Haven’t tried that yet as I’m used to conda env system. And it doesn’t seem to work there.