X11 Forwarding in PyCharm
Hi,
I have a Raspberry Pi as a remote machine and a Windows Machine running PyCharm. On the windows machine I have installed a XMing server.
I can login to the Raspberry Pi via putty and enable X11 forwarding. If I then run a simple matplotlib script, I get the plot on my Windows machine.
I would like to achieve this setup with PyCharm. Therefore I need to know, how I can enable X11 forwarding in PyCharm. I read that it suffices to put the -X switch to the ssh command: e.g: ssh -X but I don't know how to do this in PyCharm?
In another thread here on the forum I read, that it's enough to set the environment variable DISPLAY=192.168.0.18:0.0
I did this but then I get this error:
Backend TkAgg is interactive backend. Turning interactive mode on.
No protocol specified
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2431, in safe_execfile
py3compat.execfile(fname,*where)
File "/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.py", line 178, in execfile
__builtin__.execfile(filename, *where)
File "/home/pi/pywork/testcv.py", line 19, in <module>
plt.plot([1, 2, 3])
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2460, in plot
ax = gca()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 701, in gca
ax = gcf().gca(**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 369, in gcf
return figure()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "192.168.0.18:0.0"
No protocol specified
Failed to enable GUI event loop integration for 'tk'
Traceback (most recent call last):
File "/home/pi/.pycharm_helpers/pydev/pydev_console_utils.py", line 498, in do_enable_gui
enable_gui(guiname)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 509, in enable_gui
return gui_hook(app)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 262, in enable_tk
app = _TK.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "192.168.0.18:0.0"
No protocol specified
Failed to enable GUI event loop integration for 'tk'
Traceback (most recent call last):
File "/home/pi/.pycharm_helpers/pydev/pydev_console_utils.py", line 498, in do_enable_gui
enable_gui(guiname)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 509, in enable_gui
return gui_hook(app)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 262, in enable_tk
app = _TK.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "192.168.0.18:0.0"
The IP Adress and the Display number are correct, I verified this with putty....
Has anyone running a setup like this and it is working?
Kind Regards,
m
I have a Raspberry Pi as a remote machine and a Windows Machine running PyCharm. On the windows machine I have installed a XMing server.
I can login to the Raspberry Pi via putty and enable X11 forwarding. If I then run a simple matplotlib script, I get the plot on my Windows machine.
I would like to achieve this setup with PyCharm. Therefore I need to know, how I can enable X11 forwarding in PyCharm. I read that it suffices to put the -X switch to the ssh command: e.g: ssh -X but I don't know how to do this in PyCharm?
In another thread here on the forum I read, that it's enough to set the environment variable DISPLAY=192.168.0.18:0.0
I did this but then I get this error:
Backend TkAgg is interactive backend. Turning interactive mode on.
No protocol specified
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2431, in safe_execfile
py3compat.execfile(fname,*where)
File "/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.py", line 178, in execfile
__builtin__.execfile(filename, *where)
File "/home/pi/pywork/testcv.py", line 19, in <module>
plt.plot([1, 2, 3])
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2460, in plot
ax = gca()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 701, in gca
ax = gcf().gca(**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 369, in gcf
return figure()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "192.168.0.18:0.0"
No protocol specified
Failed to enable GUI event loop integration for 'tk'
Traceback (most recent call last):
File "/home/pi/.pycharm_helpers/pydev/pydev_console_utils.py", line 498, in do_enable_gui
enable_gui(guiname)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 509, in enable_gui
return gui_hook(app)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 262, in enable_tk
app = _TK.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "192.168.0.18:0.0"
No protocol specified
Failed to enable GUI event loop integration for 'tk'
Traceback (most recent call last):
File "/home/pi/.pycharm_helpers/pydev/pydev_console_utils.py", line 498, in do_enable_gui
enable_gui(guiname)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 509, in enable_gui
return gui_hook(app)
File "/home/pi/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 262, in enable_tk
app = _TK.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "192.168.0.18:0.0"
The IP Adress and the Display number are correct, I verified this with putty....
Has anyone running a setup like this and it is working?
Kind Regards,
m
Please sign in to leave a comment.
Hi Markus, I run into same issue when using PyCharm.
Have you found a solution?
It's quite annoying to always have another ssh terminal running for forwarding X11.
I'm surprised this feature is not implemented after so long.
Hi,
No, I am using Moba XTerm for now but as you said, it is very annoying.
Please vote here: https://youtrack.jetbrains.com/issue/PY-13869 perhaps we get heard ;)
use matplotlib.use('Qt5agg') or other params