I am running a python program from raspberry pi, which running this as text console mode. In normal desktop mode my program working, but when in text console mode, it says that

gtk-warning cannot open display

I want to run my program as autostart but it is not working. what is the solution??

  • To setup an autostart launcher, check this – Francesco Gusmeroli Jul 17 '17 at 13:55
  • most if not all gtk programs will require a desktop environment. Which is why it does not work from the command line but does from a terminal window. You need to launch your program using a method which does not run until the desktop is loaded, and you should probably boot to the desktop by default in that case. – Steve Robillard Jul 18 '17 at 2:02
  • so , opening an image using python from command line is not possible? – SRKP Jul 18 '17 at 5:17
  • This solved it for me: raspberrypi.org/forums/viewtopic.php?f=28&t=80848. Hope this helps. – Léonard Roussel Nov 11 '17 at 16:58

this worked for me. Open a terminal (not in super user mode), write: gksudo and when a windows open write "lxterminal" from root. Then a new terminal will open and from there run your program.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.