Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ImportError: llama-index-readers-file package not found #11336

Closed
mphipps2 opened this issue Feb 23, 2024 · 3 comments
Closed

[Bug]: ImportError: llama-index-readers-file package not found #11336

mphipps2 opened this issue Feb 23, 2024 · 3 comments
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@mphipps2
Copy link

mphipps2 commented Feb 23, 2024

Bug Description

I'm calling:
image_documents = SimpleDirectoryReader(doc_dir).load_data()

But I get a ModuleNotFoundError for llama_index.readers.file.base (inside llama_index/core/readers/file/base.py) gets called in the readers directory and the :

`=

def _try_loading_included_file_formats() -> Dict[str, Type[BaseReader]]:
try:
from llama_index.readers.file.base import (
DocxReader,
EpubReader,
HWPReader,
ImageReader,
IPYNBReader,
MarkdownReader,
MboxReader,
PandasCSVReader,
PDFReader,
PptxReader,
VideoAudioReader,
) # pants: no-infer-dep
except ImportError:
raise ImportError("llama-index-readers-file package not found")

`=

Version

llama-index: 0.10.12, llama-index-readers-file: 0.1.5

Steps to Reproduce

Call image_documents = SimpleDirectoryReader(doc_dir).load_data() using the newest release

Relevant Logs/Tracbacks

Traceback (most recent call last):
  File "/llama_index/core/readers/file/base.py", line 21, in _try_loading_included_file_formats
    from llama_index.readers.file.base import (
ModuleNotFoundError: No module named 'llama_index.readers.file.base'
  File "/llama_index/core/readers/file/base.py", line 396, in load_data
    SimpleDirectoryReader.load_file(
  File "/llama_index/core/readers/file/base.py", line 303, in load_file
    default_file_reader_cls = SimpleDirectoryReader.supported_suffix_fn()
  File "/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
@mphipps2 mphipps2 added bug Something isn't working triage Issue needs to be triaged/prioritized labels Feb 23, 2024
Copy link

dosubot bot commented Feb 23, 2024

🤖

Hey there, @mphipps2! Great to see you back. Hope you're doing well!

Based on the error message you provided, it seems like the llama_index.readers.file.base module is not found. This could be due to a few reasons:

  1. The llama_index.readers.file.base module does not exist in the version of LlamaIndex you're using. However, based on the context provided, this module should be available in LlamaIndex v0.10.12.

  2. The llama_index.readers.file.base module is not correctly installed. This could be due to an issue with your Python environment or the way LlamaIndex was installed.

To troubleshoot this issue, you can try the following steps:

  1. Create a fresh virtual environment and install LlamaIndex there. This was suggested by multiple users and confirmed to resolve the issue:
    conda deactivate
    conda create --name new_venv
    conda activate new_venv
    pip install -U llama-index
    
    If the issue persists, try force reinstalling the package without using the cache:
    pip3 uninstall llama-index
    pip3 install llama-index --upgrade --no-cache-dir --force-reinstall
    
  2. Ensure that all necessary sub-packages are installed, such as llama-index-readers-file:
    pip install -U llama-index-readers-file
    
  3. If the error still persists, it might be due to the incorrect import statement. The SimpleDirectoryReader class is located in the llama_index.legacy.readers.file.base module, not llama_index.readers.file.base. Here's how you can correct it:
    from llama_index.legacy.readers.file.base import SimpleDirectoryReader
    
    doc_dir = "/path/to/your/documents"
    image_documents = SimpleDirectoryReader(doc_dir).load_data()

Please try these steps and let me know if the issue persists. You can refer to the similar solved issue for more details.

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.

@logan-markewich
Copy link
Collaborator

logan-markewich commented Feb 23, 2024

@mphipps2 This works fine for me locally and on google colab.

Try with a fresh venv

In a new terminal:

pip uninstall llama-index  # remove any possible global install
python -m venv venv
source venv/bin/activate
pip install llama-index

(or equivalent commands for your package manager of choice)

@mphipps2
Copy link
Author

Hi Logan, thanks for the quick response. Starting the new virtual environment worked for me. Not sure where the conflict was, but either way, all good now and will close the ticket. Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized
Projects
None yet
Development

No branches or pull requests

2 participants