Cv2: cannot connect to X server

Hi everyone!
I’m trying to deploy my streamlit app (developed on Windows) on Streamlit Cloud.

Currently i’m using cv2 to create a pop-up window with the following code

1

on_mouse_color being a simple function that saves the RGB value of the clicked pixel

The problems begin after deploying said application in Streamlit Cloud, the logs show the following message:
: cannot connect to x server

This are my requirements
image

And this is my package file
image

Would appreciate help
Many thanks
Mat

You cannot use cv2 widgets, if streamlit runs on a hosted service.
This does not work because there is a fundamental misunderstanding about how Streamlit works.
Streamlit consists of a frontend and backend part.
Any interaction with streamlit must be done via the browser or browser APIs.
Anything trying to bypass this, may work on your local computer, but will fail as soon as streamlit is hosted, i.e. streamlit no longer runs on the same computer as the browser.
What happens when you try to open cv2 (or other) gui widgets?
They will be opened on the computer on which the python application is running.
But there is neither an UI nor a graphics driver on streamlit cloud and even if there was, it would be the wrong computer.
You have to rethink your whole approach, it will not work this way.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.