llama_index: Not able to use LLama Packs [Bug]:

Bug Description

I always get this error for any pack i download FileNotFoundError: [Errno 2] No such file or directory: ‘/content/chain_of_table_pack/llama_index/packs/tables/base.py’

Version

0.10.5

Steps to Reproduce

download_llama_pack( “ChainOfTablePack”, “./chain_of_table_pack”, )

Relevant Logs/Tracbacks

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-6-da45d7f3ade5> in <cell line: 3>()
      1 from llama_index.core.llama_pack import download_llama_pack
      2 
----> 3 download_llama_pack(
      4     "ChainOfTablePack",
      5     "./chain_of_table_pack",

4 frames
/usr/local/lib/python3.10/dist-packages/llama_index/core/llama_pack/download.py in download_llama_pack(llama_pack_class, download_dir, llama_pack_url, refresh_cache)
     54         )
     55     else:
---> 56         pack_cls = download_llama_pack_template(
     57             new_install_parent=new_install_parent,
     58             llama_pack_class=llama_pack_class,

/usr/local/lib/python3.10/dist-packages/llama_index/core/download/pack.py in download_llama_pack_template(new_install_parent, llama_pack_class, llama_pack_url, llama_pack_source_files_dir_path, refresh_cache, custom_dir, custom_path, base_file_name)
    124 
    125     module = util.module_from_spec(spec)
--> 126     spec.loader.exec_module(module)  # type: ignore
    127 
    128     return getattr(module, llama_pack_class)

/usr/lib/python3.10/importlib/_bootstrap_external.py in exec_module(self, module)

/usr/lib/python3.10/importlib/_bootstrap_external.py in get_code(self, fullname)

/usr/lib/python3.10/importlib/_bootstrap_external.py in get_data(self, path)

FileNotFoundError: [Errno 2] No such file or directory:

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Hi @jaideep11061982, I just tried importing both ChainOfTableQueryEngine and serialize_table and it worked for me.

Are you sure that you are using a fresh virtual environment? It looks like you’re using conda, please try this:

# conda
conda create -n venv python=3.11 anaconda # can use any Python 3.9 - 3.12 
conda activate venv
pip install llama-index llama-index-packs-tables

And with venv active:

from llama_index.packs.tables.chain_of_table.base import ChainOfTableQueryEngine, serialize_table

# these should work
# in future we can add seralize_table as top-level import but for now the above should work

Hi @dian-R no worries. Okay, I think I got you. Actually what you have experienced is the expectation in v0.10.x.

In case you missed it, in the latest big release (v0.10.x) we’ve refactored the library by splitting it into “llama-index-core” and many integration packages. The idea being that you install “core” and only the other “integration” packages you need for your application. Now, to make things simpler for our users we’ve actually included llama-index-core plus other popular integration packages (like llama-index-llms-openai) in the main package llama-index.

In terms of ChainOfTableQueryEngine, its package llama-index-packs-tables is not included in llama-index. This means, that in order to be able to import it and use it, you do have to pip install it. So, that’s why after you installed it via poetry (equivalently with pip) you were finally able to import it.

Here’s another example for you to help drive home the changes in v0.10.x. If you want to use HuggingFaceEmbeddings, you would need to install llama-index-embeddings-huggingface package as well as llama-index.

Here’s some more info on the release for you:

Thanks @jaideep11061982 for raising. Can confirm that I am able to reproduce the bug. Looks like this is caused by the logic for downloading packs not taking into account of multi-level code structure. Specifically, its looking for the base.py file, but for this pack, the “base.py” files are found one level deeper in the source code.

Will submit a fix for this shortly.