From 7587d264ea32f9ab050845196455a368294a7aae Mon Sep 17 00:00:00 2001 From: Arslan Saleem Date: Thu, 5 Oct 2023 17:16:31 +0500 Subject: [PATCH] fix: dependency move streamlit import inline (#620) --- pandasai/responses/streamlit_response.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandasai/responses/streamlit_response.py b/pandasai/responses/streamlit_response.py index e219d35d1..100d13696 100644 --- a/pandasai/responses/streamlit_response.py +++ b/pandasai/responses/streamlit_response.py @@ -1,13 +1,5 @@ from pandasai.responses.response_parser import ResponseParser -try: - import streamlit as st -except ImportError: - raise ImportError( - "The 'streamlit' module is required but not installed. " - "Please install it using pip: pip install streamlit" - ) - class StreamlitResponse(ResponseParser): def __init__(self, context): @@ -30,6 +22,14 @@ def format_plot(self, result) -> None: except OSError: raise ValueError(f"The file {result['value']} is not a valid image file.") + try: + import streamlit as st + except ImportError: + raise ImportError( + "The 'streamlit' module is required to use StreamLit Response. " + "Please install it using pip: pip install streamlit" + ) + # Display the image plt.imshow(image) fig = plt.gcf()