A community member updated LlamaIndex and encountered an error: "ImportError: cannot import name 'PromptTemplate' from 'llama_index.prompts'". The community members suggested trying to uninstall and reinstall llama-index, but the issue persisted. After reinstalling, the error occurred when trying to import PromptTemplate or call index.as_query_engine(). The community members provided the full traceback and noted that the source code looked fine. Eventually, the issue was resolved by downgrading and upgrading the package, though the exact cause was unclear.
I just updated LlamaIndex and got this error: ImportError: cannot import name 'PromptTemplate' from 'llama_index.prompts' (/Users/jana/work/LlamaIndexLangChain/jupyter/myenv/lib/python3.9/site-packages/llama_index/prompts/init.py) upon calling this query_engine = index.as_query_engine() on a vector index. Anyone experiencing the same issue and know how to resolve it?
I have reinstalled the llama-index. Error occurs when I run from llama_index.prompts import PromptTemplate trace is simple: --------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[18], line 1 ----> 1 from llama_index.prompts import PromptTemplate
ImportError: cannot import name 'PromptTemplate' from 'llama_index.prompts' (/Users/jana/work/LlamaIndexLangChain/jupyter/myenv/lib/python3.9/site-packages/llama_index/prompts/init.py)
If I run : query_engine = index.as_query_engine() then the trace is --------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[19], line 1 ----> 1 query_engine = index.as_query_engine()
File ~/work/LlamaIndexLangChain/jupyter/myenv/lib/python3.9/site-packages/llama_index/query_engine/init.py:1 ----> 1 from llama_index.query_engine.citation_query_engine import CitationQueryEngine 2 from llama_index.query_engine.flare.base import FLAREInstructQueryEngine 3 from llama_index.query_engine.graph_query_engine import ComposableGraphQueryEngine
File ~/work/LlamaIndexLangChain/jupyter/myenv/lib/python3.9/site-packages/llama_index/query_engine/citation_query_engine.py:10 8 from llama_index.indices.query.base import BaseQueryEngine 9 from llama_index.indices.query.schema import QueryBundle ---> 10 from llama_index.prompts import PromptTemplate 11 from llama_index.prompts.base import BasePromptTemplate 12 from llama_index.response.schema import RESPONSE_TYPE
ImportError: cannot import name 'PromptTemplate' from 'llama_index.prompts' (/Users/jana/work/LlamaIndexLangChain/jupyter/myenv/lib/python3.9/site-packages/llama_index/prompts/init.py)