Python Forum
Start my program in RPI4B from SSH and Failed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start my program in RPI4B from SSH and Failed
#1
I have a python program and executed (python3 myprogram1.py) from the terminal in the RPI4B works perfectly.
I wanted to run on RPI4B without the keyboard and mouse and not want use an VNC.

But when I use a terminal from windows 10 on my pc with SSH remote and tried to run my program, it said:
Output:
pi@raspberrypi:~/python $ python3 myprogram1.py Traceback (most recent call last): File "myprogram1.py", line 12, in <module> from pynput.mouse import Controller File "/home/pi/.local/lib/python3.7/site-packages/pynput/__init__.py", line 40, in <module> from . import keyboard File "/home/pi/.local/lib/python3.7/site-packages/pynput/keyboard/__init__.py", line 31, in <module> backend = backend(__name__) File "/home/pi/.local/lib/python3.7/site-packages/pynput/_util/__init__.py", line 82, in backend if resolutions else '') ImportError: this platform is not supported: ('failed to acquire X connection: Bad display name ""', DisplayNameError('')) Try one of the following resolutions: * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly
I think I must something missing with the command line?
Reply
#2
GUI programs that use Xwindows aren't directly executable on other machines through SSH.

If your local machine can run an X sserver, you can forward it through an SSH session. But that would be unusual for someone to run an X server on windows. It is possible though.

Why do you not want to run VNC? It's easier to run VNC client on windows than it is to run a full Xserver and then have the pi connect to it.

Or, could you have your program run in a command-line mode? Without a GUI, it's much easier to run non-web programs remotely.
Reply
#3
I mean I just want to launch the program to the RPI4B itself.

For example:
- I open the PuTTY with SSH and connected with the RPI4B.
- I type python3 myprogram1.py
- the RPI4B to launch the myprogram1.py to run on RPI4B's LCD itself.

that's all.
Reply
#4
I found from other forum.

use DISPLAY=:0.0 python3 myprogram1.py

it's worked!


Thank you for your helps.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to start the program from the beginning. iamaghost 5 2,872 Feb-23-2021, 03:40 AM
Last Post: deanhystad
  program will not run, errno 11001: getaddrinfo failed idioticWixen 2 3,044 Feb-29-2020, 03:14 AM
Last Post: idioticWixen
  Problem: Once I cancel the process my program will start working! Hadad 0 1,630 Jul-24-2019, 04:09 PM
Last Post: Hadad
  How can I start a python program out of a python program? peer 3 2,273 Oct-30-2018, 05:07 PM
Last Post: Larz60+
  What's the difference b/w assigning start=None and start=" " Madara 1 2,276 Aug-06-2018, 08:23 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020