Pycharm, Docker and Matplotlib on a Mac
The Issue I'm playing with Tensorflow at the moment. I'm loving PyCharm's docker integration, but the drawback I've run into is plotting Matplotlib graphs. When attempting to plot a graph, the following error occurs: RuntimeError: Invalid DISPLAY variable The Workaround The standard workaround is to save plots as images and open them from the local filesystem, like so: This is a minor annoyance, at best. The Solution But there is another way! In order to get things working in PyCharm, three steps are necessary: 1. Install and start Socat Kudos goes to this blog post for the tip and requisite install and setup instructions. 2. Make sure XQuartz is installed This one should be fairly straightforward. Worth upgrading to latest and greatest if steps do not work out of the box... 3. Edit PyCharm run/debug configuration PyCharm allows docker flags to be set via it's run/debug configuration settings. The DISPLAY environment variable needs to be set to the appropriate addr...