How to use matplotlib with a remote on PyCharm

I want to run codes with matplotlib on PyCharm. But i got an error:

_tkinter.TclError: no display name and no $DISPLAY environment variable

Before telling you that i try to solve this problem, my environment is:

 ----------               -----------------------

|  client  |  <----> |  host  | container |

 ----------               -----------------------

client's OS: Windows 10

host's OS: Ubuntu 16.04

The container is running from Docker and have a port that forwarded 22 to 8022 on host. I can connect a remote Python interpreter in a running container using PyCharm functionality. And it works well.

Now, to use matplotlib in my project. i run a command 'xhost +' and on client i run Xming + putty to test. it works well and i can see the display name using "echo $DISPLAY" on putty terminal.

But, when i try to do on PyCharm. The error above is occurred. I did some many research such as set to DISPLAY environment variable on PyCharm, Change to python backend TkAgg to GTKAgg, Agg, and so on. 

Anyway i got an idea that on putty terminal i can get the display name with "echo $DISPLAY" that show me "1816c3f79320:10.0". And i set the DISPLAY in run configuration on PyCharm to "1816c3f79320:10.0". It works well. But, this method is really bad thing. Because when i run a new putty terminal. Sometimes the display name will be changed so i need to reset run configuration on PyCharm.

Additionally, I know that PyCharm supports SciView and it works well. But i do not want to use it.

Do you guys have any idea to solve this problem?

 

Please sign in to leave a comment.