Pycharm: no display name and no $DISPLAY environment variable

I've been working with PyCharm for a couple of weeks now.  My development machine is a PC running Windows 10, and the target is a Raspberry Pi 3B+ running Raspberry Pi OS.  I have the remote settings configured so I can hit "run" on the Windows machine and it will update the code on the Pi, and run the first part of the code - (ssh://pi@192.168.1.3:22/usr/bin/python3 -u -m main), printing the text console output from the Pi on the PC, but as soon as I try to do anything with tkinter in the code, it tells me "no display name and no $DISPLAY environment variable".  I've tried various suggestions found using Google, but nothing seems to be working.  If I go to the HDMI/keyboard/mouse connected to the Pi and run "python3 main" in the target directory, the tkinter windows and buttons work fine.  Can you help?



Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/pi/projects/dt_test_fixture/main.py", line 20, in <module>
style = ttk.Style()
File "/usr/lib/python3.7/tkinter/ttk.py", line 368, in __init__
master = setup_master(master)
File "/usr/lib/python3.7/tkinter/ttk.py", line 354, in setup_master
master = tkinter._default_root or tkinter.Tk()
File "/usr/lib/python3.7/tkinter/__init__.py", line 2023, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Process finished with exit code 1

Please sign in to leave a comment.