Failed to connect to Mir:Failed to connect to server socket:No such file or directory

error when running.py file under Linux:

Failed to connect to Mir:Failed to connect to server socket:No such file or directory

Google to the solution, in the terminal input instruction:

export DISPLAY=:0 

and then run the.py file ~

but this is only a temporary solution, you have to execute this command every time you open the terminal.
solution:

Add

to the end of file for /etc/sudoers:

Defaults env_keep+="DISPLAY"

since this file requires write permissions, open it with the following command:

sudo visudo

open the file and add:

here


after save the file is ok ~

Notes:
remember to always use “+ =” when adding to env_keep. If there are any other EN v_keep with “=” change them to “+ =” because using “=” will overwrite other values.

Ps: but this method suddenly doesn’t work at the moment, so we have to use export DISPLAY every time.

Read More: