SciView with SSH remote interpreter

Hi, I'm trying to get SciView working with an SSH remote interpreter. The SSH endpoint happens to be inside a Docker container on a remote host, and I can't run it in the host network namespace or mount extra device files to it.

By default, matplotlib.get_backend() shows 'module://backend_interagg'. If I run:

import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()

the plot doesn't show. If I instead use the TkAgg backend,

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()

I get an error: "_tkinter.TclError: no display name and no $DISPLAY environment variable" . If I ssh in to the container with -Y, echo $DISPLAY, then copy that environmental variable in the SSH remote interpreter's os.environ and re-run the above code, the plot shows up in a separate X11 window.

Is there a way to get the plot to show up in the SciView window?

Thanks,

Anand

5 comments
Comment actions Permalink

Seems like the following issue: https://youtrack.jetbrains.com/issue/PY-32668

Are you using '-XY' flags for SSH connection?

0
Comment actions Permalink

Thanks for getting back to me. How can I get PyCharm to use the -XY flags? In the project remote interpreter settings, I don't see a field where I can enter extra CLI arguments for SSH.

0
Comment actions Permalink

Sorry for the delayed response.

Yeah, it seems I overlooked it. there's no way to configure options for remote deployment in PyCharm.

Are you connecting to docker container directly, or using SSH tunnel?

0
Comment actions Permalink

I've configured a PyCharm project's remote interpreter to SSH directly to the container. What do you mean by using an SSH tunnel?

0
Comment actions Permalink

Which Docker image are you using? I've tried using `python:3.6`.

I started the container:

`docker run -it python:3.6 /bin/bash`

Then installed openssh-server, installed `matplotlib` for python, created user which I would use for connection, configured SSH interpreter to connect directly to that container, and when I run your first code sample, the plot is shown, so it works.

I suggest doing the above test to confirm it's working, which would mean the issue is in your container/environment.

0

Please sign in to leave a comment.