Find answers from the community

Updated last year

Hey all i m trying to use llama index

Hey all, i'm trying to use llama_index from main since it contains a fix for a breaking llama-cpp change, but I can't seem to figure out how.
I set up poetry to pull from the llama_index github, but when I try importing ServiceContext I'm met with this error

Plain Text
>>> from llama_index import ServiceContext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/benbot/.cache/pypoetry/virtualenvs/llamaindex-learn-LAh3hCYO-py3.11/lib/python3.11/site-packages/llama_index/__init__.py", line 41, in <module>
    from llama_index.indices.struct_store.sql import (
  File "/home/benbot/.cache/pypoetry/virtualenvs/llamaindex-learn-LAh3hCYO-py3.11/lib/python3.11/site-packages/llama_index/indices/struct_store/__init__.py", line 5, in <module>
    from llama_index.indices.struct_store.sql import (
  File "/home/benbot/.cache/pypoetry/virtualenvs/llamaindex-learn-LAh3hCYO-py3.11/lib/python3.11/site-packages/llama_index/indices/struct_store/sql.py", line 9, in <module>
    from llama_index.indices.common.struct_store.sql import SQLStructDatapointExtractor
  File "/home/benbot/.cache/pypoetry/virtualenvs/llamaindex-learn-LAh3hCYO-py3.11/lib/python3.11/site-packages/llama_index/indices/common/struct_store/sql.py", line 8, in <module>
    from llama_index.indices.common.struct_store.base import (
  File "/home/benbot/.cache/pypoetry/virtualenvs/llamaindex-learn-LAh3hCYO-py3.11/lib/python3.11/site-packages/llama_index/indices/common/struct_store/base.py", line 10, in <module>
    from llama_index.utilities.sql_wrapper import SQLDatabase
ModuleNotFoundError: No module named 'llama_index.utilities'


I'm not really an expert in the python packaging system and I can't find any instructions for running llama_index from main, so if anyone knows how it'd be a big help πŸ˜…
L
B
21 comments
you might need to uninstall and then re-install from source

Plain Text
pip uninstall llama-index
pip install -e .
but i'm using poetry, not just pip :\

Uninstalling and reinstalling using poetry doesn't work.

Uninstalling and reinstalling using the pip command also didn't work, but differently. I'm seeing

Plain Text
>>> from llama_index import ServiceContext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'ServiceContext' from 'llama_index' (unknown location)
>>> 

now πŸ˜…
I ran poetry run pip install -e ./llama-index
you can still use pip with poetry -- poetry shell creates a venv, and pip will install into it
At least it works that way for me πŸ˜…
let me give it a shot. I am just starting to use poetry Β―\_(ツ)_/Β―
that seemed to work. I wonder why it was having issues before :\
oh wait no nvm :\
so if i'm not in the llama-index directory it can't find llama-index
hmm πŸ€”
you did

Plain Text
pip uninstall llama-index
pip install -e .


And then when you move out of the directory, it barfs?
yeah, it gives me that unknown location error again
is it because you moved to a directory that has a folder named llama_index in it?
0_0 i do.

rn it's /myproject and there is a /myproject/llama_index
maybe rename that
it's trying to import from that folder and failing
python is fun
I'm from javascript land. I'm used to this kind of "fun" at least lol
that seemed to fix it
thanks a bunch πŸ™‚
Add a reply
Sign up and join the conversation on Discord