docker remote interpreter and matplotlib

Answered

I am start to using docker remote interpreter. Everything works great except it seems the SciView no longer showing output of matplotlib. Do I missing some thing or this is a feature not support yet?

same project, by using local interpreter (virtualenv) when I run the code, I will see plot graph on "SicView" 

by switch to a remote Docker interpreter, when I run the code, I only see output with "exit code 0", plot is not showing on "SicView"

9 comments
Comment actions Permalink

Hi Rui Vapps, PyCharm doesn't support showing plots with Docker-based interpreters. Here's a relevant comment: https://youtrack.jetbrains.com/issue/PY-18102#focus=streamItem-27-1412306-0-0

0
Comment actions Permalink

Pavel: does this limitation applies to the case when PyCharm runs on Linux (Ubuntu), and the docker interpreter runs as a local image?

It seems that the limitation does apply as I can't get matplotlib to display, but wanted to double check!

Thanks!

0
Comment actions Permalink

one workaround which solved my problems was this: https://youtrack.jetbrains.com/issue/PY-27489

0
Comment actions Permalink

on linux you can get around this issue by adding adding `-e DISPLAY` and `-v /tmp/.X11-unix:/tmp/.X11-unix` to the configuration

0
Comment actions Permalink

@Linushn93

Could you please explain your fix more detailed?  Where did you add these options? Does linux have to be the same version (ie. local os is ubuntu 18.04 -> docker os is ubuntu 18.04 too?)

 

Thanks in advance!

0
Comment actions Permalink

Go to your run configurations (top right corner) -> edit configurations -> docker configuration and set DISPLAY to :0 (or whatever it is on your system) in the environment variables and map /tmp/.X11-unix to /tmp/.X11-unix to the volumes. I don't know if there are any version requirements (I am using ubuntu 16 on both the host and container)

2
Comment actions Permalink

One addition to the answer by @Linushn93. You should use host networking for the container. This way PyCharm will display figures in SciView.

2
Comment actions Permalink

In case anybody wants a step by step explanation to solve this issue and be able to use Matplotlib while using Pycharm as IDE and docker as interpreter. [This post is based on the answer by @Linushn93] [It works on Ubuntu 16.04 (and probably for several other distributions of the Linux)]

 

1. First step is to make sure that your Docker interpreter is configured properly. Make sure that you are able  to run your code using Docker interpreter (except those that are plotting something, of course!)

2. Go to Run/debug configurations dialog and click on Edit Configurations

 

3. Open Docker Container Settings

 

4. Do all these settings here:

- put host in the Network mode  (as Gleb Sizov mentioned in his response)

- add a Volume boundings like in the picture (/tmp/.X11-unix to /tmp/.X11-unix)

- add an entry like the following picture to the Environmental variables section (Name is DISPLAY and Value is :0)

Are you expecting more? That's is, have fun with the rest of your project :))

One of my plots after making it work.

[@alisaaalehi]

2

Please sign in to leave a comment.