I am using PyCharm 2017.2.3 and python 2.7 on Ubuntu 16.04. I am running into an issue trying to use matplotlib for plotting even a simple code as next one.
from matplotlib import pyplot as plt
import matplotlib.image as mpimg
image = mpimg.imread("chelsea-the-cat.png")
plt.imshow(image)
plt.show()
Apparently there is no errors or warnings, just the running script get stuck. But when using debug, the debug console print out this:
/home/esromerom/.virtualenvs/cv/bin/python /opt/pycharm-2017.2.3/helpers/pydev/pydevd.py --multiproc
--qt-support=auto --client 127.0.0.1 --port 45601 --file
"/media/esromerom/TOSHIBA EXT/grado/cv/image.py" pydev debugger: process 14506 is connecting
Connected to pydev debugger (build 172.3968.37)
Failed to enable GUI event loop integration for 'tk'
Traceback (most recent call last):
File "/opt/pycharm-2017.2.3/helpers/pydev/pydev_ipython/matplotlibtools.py", line 31, in do_enable_gui
enable_gui(guiname)
File "/opt/pycharm-2017.2.3/helpers/pydev/pydev_ipython/inputhook.py", line 528, in enable_gui
return gui_hook(app)
File "/opt/pycharm-2017.2.3/helpers/pydev/pydev_ipython/inputhook.py", line 278, in enable_tk
app = _TK.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1818, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: couldn't connect to display "True"
Backend TkAgg is interactive backend. Turning interactive mode on.
TkAgg
I have already tried the recommended solutions for similar issues, but the script still no shows anything. (Check matplotlib Backend, re-install tk libraries, re-install matplotlib, add "DISPLAY=True" in Run/Debug Configurations, ...)
Does anybody have any idea of how make it happens?