"... trouble accessing the component frontend assets..." when loading streamlit app with custom components via CLI wrapper script

I created an app (‘main.py’) utilizing the custom components (streamlit_image_coordinates) which works fine when I start the streamlit app normally in command prompt with:

streamlit run main.py

As I am required to package the app with pyinstaller, I have created a wrapper script ‘run_main.py’ with following scripts:

import sys
from streamlit.web import cli as stcli

if __name__ == '__main__':
    sys.argv = ['streamlit', 'run', './main.py']
    sys.exit(stcli.main())

Whenever I launch the app via the wrapper script ‘run_main.py’, the section that render the custom component (streamlit_image_coordinates) will show the error:

Your app is having trouble loading the streamlit_image_coordinates.streamlit_image_coordinates component.

If this is an installed component that works locally, the app may be having trouble accessing the component frontend assets due to network latency or proxy settings in your app deployment.

However, the custom component works fine when I launch the main script directly with:

streamlit run main.py

I suspect this is caused by the wrapper script but I have not been able to find any workaround. I needed the wrapper script as otherwise I cannot package the app with pyinstaller. Any advice pls?

Environments:

  • running app locally
  • streamlit v1.39.0
  • streamlit-image-coordinates v0.1.9
  • python v3.8

PyInstaller may not automatically package all required frontend files for the custom component. Use a --collect-alloption for the streamlit_image_coordinates package:

pyinstaller --collect-all streamlit_image_coordinates run_main.py

After packaging, inspect the dist directory to ensure all required files for streamlit_image_coordinates are present.

Thanks. I repackaged with pyinstaller as per advice but it is still showing the same error. The streamlit_image_coordinates was included in the dist folder but the error still shows up.

In fact, the error is showing up even before going through pyinstaller, ie, even when running in my python environment with:

python run_main.py

The component is working fine without starting the app through the wrapper script “run_main.py”, ie, it is fine if I start the app with:

streamlit run main.py