解决方法主要来自stackoverflow:
python-plotting-on-remote-server-using-pycharm
remote-debugging-with-pycharm-unable-plot-figure-on-local-machine
Ok, after some more googling I finally managed to get this process working, hope it helps somebody:
1) on remote host (VPS, Ubuntu 16.04) I had to install X11 server,
which I did by:sudo apt-get install xorg sudo apt-get install openbox 2) On remote
host I had to make sure that X11Forwarding is enabled in
/etc/ssh/sshd_config3) On local Win10 machine I had to install Xming server and launch it
with default settings.4) On local Win10 machine I had to configure Putty to use X11
forwarding (Connection-> SSH -> X11 Forwarding) with default settings
and keep connection open while running PyCharm (it seems there is no
option in PyCharm to enable x11 forwarding, so putty must be running
in the background)5) On remote machine I had to check Display number (echo $DISPLAY) -
this can be different for everyone. For me it was localhost:10.06) In PyCharm Run configuration -> Environment variables I had to add
DISPLAY=localhost:10.0After all these steps and Putty+Xming running in backgroud, I was able
to execute remote code and bring graphic back to my Windows 10 PC!PS - process is actually slow, I have to wait around 10 seconds before
image is brought back to me. I am not sure why or how to speed it up.
Might be another question. (reducing chipher strength and enabling
compression does not help. It seems some sort of initialization
problem with x11 remote and local)
x服务器选用xmanager、shell选用xshell可参考:
LINUX上pycharm远程解释器运行py程序在本地机器上显示plot命令画出来的图像
PyCharm远程开发调试,解决mtplotlib不显示图像问题
按照上文操作后仍无法正常显示则:
On Mac, it can be solved by, uncheck Settings | Tools | Python Scientific | Show Plots in Toolwindow. – Rockie Yang Mar 15 at 15:14