Find answers from the community

Updated 3 months ago

Hi, I have a Flask app that crashes on

Hi, I have a Flask app that crashes on loading with the following stacktrace. Any idea what could be causing this and how to fix it?
My pipfile:
llama-index-core = ">=0.10" llama-index-vector-stores-qdrant = "*" llama-index-embeddings-openai = "*" llama-index-llms-openai = "*"
resolves to:
llama-index==0.9.45.post1 llama-index-agent-openai==0.1.6 llama-index-cli==0.1.11 llama-index-core==0.10.21.post1 llama-index-embeddings-openai==0.1.7 llama-index-indices-managed-llama-cloud==0.1.4 llama-index-legacy==0.9.48 llama-index-llms-openai==0.1.12 llama-index-multi-modal-llms-openai==0.1.4 llama-index-program-openai==0.1.4 llama-index-question-gen-openai==0.1.3 llama-index-readers-file==0.1.11 llama-index-readers-llama-parse==0.1.3 llama-index-vector-stores-qdrant==0.1.4
Attachment
image.png
L
J
13 comments
you have llama-index-v0.9.x installed
probably thats a mistake?
I'm rebuilding with a fresh venv every time. the dependencies are somehow resolving to pull that in. If I take out llama-index-core and just use llama-index I get these errors:
Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last):
File "/Users/jimkleban/.local/share/virtualenvs/mlapi-1g7jvfBV/lib/python3.11/site-packages/flask/cli.py", line 218, in locate_app
import(module_name)
File "/Users/jimkleban/supernormal/mlapi/app.py", line 1, in <module>
from api import app
File "/Users/jimkleban/supernormal/mlapi/api/init.py", line 11, in <module>
import api.config as config
File "/Users/jimkleban/supernormal/mlapi/api/config.py", line 60, in <module>
RAG_SENTENCE_SPLITTER = SentenceSplitter(
^^^^^^^^^^^^^^^^^
File "/Users/jimkleban/.local/share/virtualenvs/mlapi-1g7jvfBV/lib/python3.11/site-packages/llama_index/core/node_parser/text/sentence.py", line 87, in init
callback_manager = callback_manager or CallbackManager([])
^^^^^^^^^^^^^^^^^^^
File "/Users/jimkleban/.local/share/virtualenvs/mlapi-1g7jvfBV/lib/python3.11/site-packages/llama_index/core/callbacks/base.py", line 54, in init
from llama_index.core import global_handler
ImportError: cannot import name 'global_handler' from 'llama_index.core' (unknown location)
So like, in v0.10.x all integrations got split into different packages. This cant be mixed with old v0.9.x stuff

This installs fine and imports fine on a fresh venv for me. Also works in google colab
I would suggest, in a new terminal

Plain Text
pip uninstall llama-index # remove any global
python -m venv venv
source venv/bin/activate
pip install llama-index llama-index-vector-stores-qdrant
The problem I have is this part of a bigger app, so Pipfile is more than the libraries I listed. If I do the equivalent and install llama-index I get reasonable libraries (no more 0.9) but errors on execution I listed
llama-index==0.10.20
llama-index-agent-openai==0.1.6
llama-index-cli==0.1.11
llama-index-core==0.10.21.post1
llama-index-embeddings-openai==0.1.7
llama-index-indices-managed-llama-cloud==0.1.4
llama-index-legacy==0.9.48
llama-index-llms-openai==0.1.12
llama-index-multi-modal-llms-openai==0.1.4
llama-index-program-openai==0.1.4
llama-index-question-gen-openai==0.1.3
llama-index-readers-file==0.1.11
llama-index-readers-llama-parse==0.1.3
llama-index-vector-stores-qdrant==0.1.4
llama-parse==0.3.9
llamaindex-py-client==0.1.13
BTW, thank you very much Logan
You did this in a fresh venv? Like for sure? It really is just an env issue

Like I mentioned, the steps above solve it 99% of the time, unless one of your deps is pulling in llama-index v0.9.x
Thanks. Taking more steps to make sure the venv was really fresh did fix the errors.
I use Heroku to deploy this app, and I still see the global_handler errors when I deploy with the revised Pipfile there. There is no concept of a fresh venv there as it installs from a fresh venv each time.
Maybe it's a heroku thing, thoguh
The heroku thing I needed to do turned out to be heroku repo:purge_cache in case anyone else hits this
Add a reply
Sign up and join the conversation on Discord