X11 Forwarding in PyCharm

Answered

I'm currently working on an object detection project, which I want to run on an Amazon EC2 over SSH with my MacBook Pro. The project works well locally, but when I run it over SSH I get "(Detector:5968): Gtk-WARNING **: cannot open display: " when I try to execute the line:

cv2.imshow('Detector', cv2.resize(image_np, (800, 600)))

I've tried to enable X11 Forwarding in the ssh_config-files, both locally and on the ec2. I've also tried to set the Display variable but I can't get it to work. What am I missing?

4 comments
Comment actions Permalink

Unfortunately, PyCharm doesn't support X11 forwarding at this moment.

The related ticket from our issue tracking system https://youtrack.jetbrains.com/issue/PY-13869, please upvote and follow for updates.

You could try the workaround mentioned there: https://stackoverflow.com/questions/41892039/how-to-enable-x11-forwarding-in-pycharm-ssh-session

0
Comment actions Permalink

What worked for me was running "xhost +" in the terminal to disable access control and then starting an SSH session with the -X or -Y flag (leave it running). After that, X11 Forwarding worked in my PyCharm project with the correct Display variable set in Environment variables.

0
Comment actions Permalink

Hi Johol920, I tried your trick, but it did not work for me <sigh>. You were saying use the terminal inside PyCharm, correct? Not from say, Mate Terminal? I downloaded the intellij-community repo, look through the code base at all the PythonRemote* and PyRemote* classes, and then download the guide. It is a rabbit hole. I just went and installed PyCharm on the remote VM and access it through ssh, which has X11 <sad shake of  head>. Thank you though.

0
Comment actions Permalink

Frederick, I actually just opened a separate terminal outside of PyCharm

0

Please sign in to leave a comment.