Combination of PyCharm and ipython fails to import qt5 or Qt5Agg
<p>I have installed elementary os and Pycharm and the whole python stack via <code>conda</code>, and now have troubles starting interactive matplotlib in the <code>ipython</code> sesssion.</p>

<p>Here's pycharm's ipython session:</p>

<pre><code>/home/foo/.conda/envs/myenv3/bin/python3.5 /opt/pycharm-2016.2.3/helpers/pydev/pydevconsole.py 41070 33134
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.
?         -&gt; Introduction and overview of IPython's features.
%quickref -&gt; Quick reference.
help      -&gt; Python's own help system.
object?   -&gt; Details about 'object', use 'object??' for extra details.
PyDev console: using IPython 5.0.0

import sys; print('Python %s on %s' % (sys.version, sys.platform))

Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
</code></pre>

<p>And here is what happens if I try to import <code>pyplot</code>:</p>

<pre><code>In[4]: import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "/opt/pycharm-2016.2.3/helpers/pydev/pydev_ipython/inputhook.py", line 502, in enable_gui
    gui_hook = guis[gui]
KeyError: 'qt5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/pycharm-2016.2.3/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 123, in enable_gui
    return real_enable_gui(gui, app)
  File "/opt/pycharm-2016.2.3/helpers/pydev/pydev_ipython/inputhook.py", line 508, in enable_gui
    raise ValueError(e)
ValueError: Invalid GUI request 'qt5', valid ones are:dict_keys(['gtk3', 'wx', 'qt', 'osx', 'pyglet', 'glut', 'tk', 'gtk', 'none', 'qt4'])

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2869, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "&lt;ipython-input-4-eff513f636fd&gt;", line 1, in &lt;module&gt;
    import matplotlib.pyplot as plt
</code></pre>

<ul>
<li>This problem only happens when <code>ipython</code> is installed. <strong>When I don't select ipython, however, I only get an irresponsive black screen when I <code>plt.figure()</code></strong>.</li>
<li>This problem does not happen when I start <code>ipython</code> manually from the terminal (outside of pycharm). Also, if I do <code>matplotlib.use('Qt5Agg')</code> before importing <code>pyplot</code>, the error persists in pycharm, but does not appear in the ipython console in my terminal.</li>
<li>Installing on a new conda environment following <code>conda create -n test python=3.5 ; conda install ipython matplotlib scipy -n test</code> and loading the new environment in pycharm did not help</li>
<li>Reinstalling pycharm 2.3 or Invalidate Caches + Restart did not help</li>
<li>Installing pycharm educational 3.0 did not help</li>
</ul>

<p>How can I get this to work?</p>

<p>Pycharm appears to not fully support <code>qt5</code>, the issue is <a href="https://youtrack.jetbrains.com/issue/PY-20981" rel="nofollow">open</a>. Downgrading it is the fastest workaround. </p>

<p>With conda the following will perform a downgrade to the last stable version:</p>

<pre><code>conda install pyqt=4.11.4 
</code></pre>

python matplotlib pyqt ipython pycharm