Edwin Salguero commited on
Commit ·
50a66f8
1
Parent(s): b204d55
Fix Streamlit Cloud deployment import issue - Added robust import handling with fallbacks - Added current directory to Python path - Added error handling for import failures - Improved debugging output for deployment troubleshooting
Browse files12 unmodified lines131415161718192012 unmodified linesif frontend_dir not in sys.path:sys.path.insert(0, frontend_dir)# Import only the main function to avoid loading unnecessary modulesfrom app import main# Run the main function directlyif __name__ == "__main__":12 unmodified lines1314151617181920212223242526272829303132333435363738394012 unmodified linesif frontend_dir not in sys.path:sys.path.insert(0, frontend_dir)# Add the current directory to the path as wellif current_dir not in sys.path:sys.path.insert(0, current_dir)try:# Import only the main function to avoid loading unnecessary modulesfrom frontend.app import mainprint("Successfully imported main function from frontend.app")except ImportError as e:print(f"Error importing from frontend.app: {e}")try:# Fallback: try importing directlyfrom app import mainprint("Successfully imported main function from app")except ImportError as e2:print(f"Error importing from app: {e2}")# Last resort: define a simple main functionimport streamlit as stdef main():st.error("Failed to import main application. Please check the deployment.")st.info("Contact support if this issue persists.")print("Using fallback main function")# Run the main function directlyif __name__ == "__main__":
streamlit_app.py+22-2