_tkinter.TclError: couldn’t connect to display “localhost:0.0” matplotlib bash on windows

Posted on


Insipired by the problems with displaying matplotlib used in a Python script using the terminal of the Bash (Ubuntu) on Windows, I have followed the instructions listed in the first answer. However, after restarting the computer, suddenly I get an error:

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

Do you have any idea how to fix it and display images?

Citing the mentioned post, I have:

  1. Downloaded and installed Xming
  2. sudo apt-get update
  3. sudo apt-get install python3.6-tk
  4. (installed matplotlib earlier)
  5. export DISPLAY=localhost:0.0 and added to ~/.bashrc


Don’t forget to open the Xming application on Windows before running the script in the Ubuntu subsystem.

Leave a Reply

Your email address will not be published. Required fields are marked *