Если я попробую выполнить следующее в консоли Windows, все будет работать отлично:
- ssh -X user@raspberrypi
- export DISPLAY=:0
- python3 my_gui_app.py
Код: Выделить всё
import paramiko
hostname = "raspberrypi"
username = "user"
password = "1234"
command = "python3 my_gui_app.py"
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(hostname=hostname, username=username, password=password)
with client.get_transport().open_session() as session:
session.get_pty()
session.request_x11(single_connection=True)
session.set_environment_variable("DISPLAY", ":0")
session.exec_command(command)
# Continuously read the stdout and stderr streams
while True:
if session.recv_ready():
stdout = str(session.recv(4096).decode("utf-8"))
print(stdout, end="")
if session.recv_stderr_ready():
stderr = str(session.recv_stderr(4096).decode("utf-8"))
print(stderr, end="")
# Check if the command has finished executing
if session.exit_status_ready():
break
finally:
client.close()
Подробнее здесь: https://stackoverflow.com/questions/779 ... n-paramiko