DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Gtk-WARNING when using subprocess.Popen

Fri Aug 12, 2016 11:29 pm

Hi, I am getting this error when trying to open a new terminal window via SSH using the subprocess package in Python 2.7...

Code: Select all

(lxterminal:1648): Gtk-WARNING **: cannot open display:
Here is my code...

Code: Select all

#The main executable, invokes all required scripts.

from sys import executable
from subprocess import *
import operations #Dont worry about this, this is my own library

operations.setupGPIO()

pid = Popen(args=[
    "lxterminal", "--command=python /home/pi/Doucments/Python/RoomAccess/input.py"], shell=True).pid
I have tried using 'startx' in conjunction with the command I am using now, like this...

Code: Select all

pid = Popen(args=[
    "lxterminal", "--command=startx python /home/pi/Doucments/Python/RoomAccess/input.py"], shell=True).pid
but I still receive the same error.

I have looked around for fixes but they are all for other Linux distributions, can anyone offer any help, any will be greatly appreciated :D

Thanks in advance :D

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Gtk-WARNING when using subprocess.Popen

Sat Aug 13, 2016 11:31 am

Can anyone think of anything? :D

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Gtk-WARNING when using subprocess.Popen

Sat Aug 13, 2016 1:30 pm

Lxterminal is an X-windows client application. It needs access to a system running an X-windows server to render the graphical display.

It might be that all you need to do is invoke ssh with the x-forwarding option enabled. The ssh command line client has a switch, -X, to enable this.

Startx is not an appropriate command to issue from a remote login: if you want to recreate the Big Raspberry GUI the shell command to use is

Code: Select all

startlxde-pi

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Gtk-WARNING when using subprocess.Popen

Sat Aug 13, 2016 6:15 pm

Thanks, this worked :D

Return to “Python”