I'm trying to execute a python script through Node-RED, and while previously it worked, I had to format my Raspberry Pi and now it no longers works.
The errors it outputs is "cannot connect to X server". The script works fine if I execute it in a Raspberry terminal, and when I reinstalled Node-RED I imported my previous flow, so everything is exactly as it was before.
Here is a picture with the exec node configuration.
Is there any configuration on the Raspberry Pi I might have missed out while installing it again or is the problem coming from Node-RED?
...means that your code is trying (and failing) to connect to an X server -- a GUI environment -- presumably being forwarded over your SSH session.
If you want to stop it from being able to make any GUI connection at all (and perhaps, if the software is thusly written, from even trying), unset the DISPLAY environment variable before running your code.
My script is a QR reader that uses a camera module to scan qr codes in the field of view, the script shows a window that displays the cameras field of view.
Using the "DISPLAY=:0" allows the script to run but it no longer functions as before, previously when it detected a QR code it would output the QR code contents in Node-RED, but using "DISPLAY=:0" it doesn't output the QR code content.
Yeah it does, but I fixed the issue by importing an older version of my flow. Maybe something went wrong when importing since I didn't have everything installed yet.