Running Pygame and Tkinter with X11 forwarding

You can get the following error (or similar) when running the Pygame or Tkinter scripts:

_tkinter.TclError: couldn't connect to display "localhost:10.0"  

In this case, use the following command to fix the error:

sudo cp ~/.Xauthority ~root/ 

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.