<p dir="auto"><code class="notranslate">import matplotlib.pyplot as plt</code> is erroring for matplotlib-1.5.3 while trying to import from PyQt4.</p>
<p dir="auto">I have observed this while running on Travis-CI, linux, installing matplotlib using conda. Here is a trace-back from the python 3.4.2 failure (<a href="https://travis-ci.org/simpeg/simpeg/jobs/160737799" rel="nofollow">https://travis-ci.org/simpeg/simpeg/jobs/160737799</a>), for 2.7.9, there is an example in the travis log: <a href="https://travis-ci.org/simpeg/simpeg/jobs/160737812" rel="nofollow">https://travis-ci.org/simpeg/simpeg/jobs/160737812</a>)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
  File &quot;/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/pyplot.py&quot;, line 114, in &lt;module&gt;
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File &quot;/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/__init__.py&quot;, line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File &quot;/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/backend_qt4agg.py&quot;, line 18, in &lt;module&gt;
    from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
  File &quot;/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/backend_qt5agg.py&quot;, line 16, in &lt;module&gt;
    from .backend_qt5 import QtCore
  File &quot;/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/backend_qt5.py&quot;, line 31, in &lt;module&gt;
    from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
  File &quot;/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/qt_compat.py&quot;, line 137, in &lt;module&gt;
    from PyQt4 import QtCore, QtGui
ImportError: No module named 'PyQt4'"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt
  File "/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/pyplot.py", line 114, in &lt;module&gt;
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/backend_qt4agg.py", line 18, in &lt;module&gt;
    from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
  File "/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in &lt;module&gt;
    from .backend_qt5 import QtCore
  File "/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/backend_qt5.py", line 31, in &lt;module&gt;
    from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
  File "/home/travis/miniconda/lib/python3.4/site-packages/matplotlib/backends/qt_compat.py", line 137, in &lt;module&gt;
    from PyQt4 import QtCore, QtGui
ImportError: No module named 'PyQt4'
</code></pre></div>
<p dir="auto">The environment is</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    package                    |            build
    ---------------------------|-----------------
    expat-2.1.0                |                0         365 KB
    icu-54.1                   |                0        11.3 MB
    jpeg-8d                    |                1         806 KB
    libffi-3.2.1               |                0          36 KB
    libgcc-5.2.0               |                0         1.1 MB
    libgfortran-3.0.0          |                1         281 KB
    libxcb-1.12                |                0         1.5 MB
    mkl-11.3.3                 |                0       122.1 MB
    dbus-1.10.10               |                0         2.4 MB
    glib-2.43.0                |                1         5.4 MB
    libpng-1.6.22              |                0         214 KB
    libxml2-2.9.2              |                0         4.2 MB
    alabaster-0.7.9            |           py34_0          11 KB
    cython-0.24.1              |           py34_0         6.3 MB
    decorator-4.0.10           |           py34_0          12 KB
    docutils-0.12              |           py34_2         673 KB
    freetype-2.5.5             |                1         2.5 MB
    gstreamer-1.8.0            |                0         2.6 MB
    imagesize-0.7.1            |           py34_0           3 KB
    ipython_genutils-0.1.0     |           py34_0          33 KB
    markupsafe-0.23            |           py34_2          32 KB
    mpmath-0.19                |           py34_1         901 KB
    nose-1.3.7                 |           py34_1         196 KB
    numpy-1.11.1               |           py34_0         6.1 MB
    path.py-8.2.1              |           py34_0          47 KB
    ptyprocess-0.5.1           |           py34_0          19 KB
    pygments-2.1.3             |           py34_0         1.2 MB
    pyparsing-2.1.4            |           py34_0          72 KB
    pytz-2016.6.1              |           py34_0         177 KB
    pyyaml-3.12                |           py34_0         348 KB
    setuptools-27.2.0          |           py34_0         528 KB
    simplegeneric-0.8.1        |           py34_1           7 KB
    sip-4.18                   |           py34_0         240 KB
    six-1.10.0                 |           py34_0          17 KB
    snowballstemmer-1.2.1      |           py34_0          79 KB
    sphinx_rtd_theme-0.1.9     |           py34_0         628 KB
    wcwidth-0.1.7              |           py34_0          21 KB
    wheel-0.29.0               |           py34_0          82 KB
    babel-2.3.4                |           py34_0         4.8 MB
    cycler-0.10.0              |           py34_0          11 KB
    fontconfig-2.11.1          |                6         405 KB
    gst-plugins-base-1.8.0     |                0         3.1 MB
    jinja2-2.8                 |           py34_1         304 KB
    pexpect-4.0.1              |           py34_0          66 KB
    pickleshare-0.7.4          |           py34_0           9 KB
    pip-8.1.2                  |           py34_0         1.6 MB
    prompt_toolkit-1.0.3       |           py34_0         309 KB
    python-dateutil-2.5.3      |           py34_0         238 KB
    scipy-0.18.0               |      np111py34_0        30.7 MB
    sympy-1.0                  |           py34_0         5.9 MB
    traitlets-4.3.0            |           py34_0         125 KB
    ipython-5.1.0              |           py34_0         994 KB
    qt-5.6.0                   |                0        43.9 MB
    sphinx-1.4.1               |           py34_0         1.3 MB
    pyqt-5.6.0                 |           py34_0         5.2 MB
    matplotlib-1.5.3           |      np111py34_0         8.4 MB
    ------------------------------------------------------------
                                           Total:       279.6 MB"><pre class="notranslate"><code class="notranslate">    package                    |            build
    ---------------------------|-----------------
    expat-2.1.0                |                0         365 KB
    icu-54.1                   |                0        11.3 MB
    jpeg-8d                    |                1         806 KB
    libffi-3.2.1               |                0          36 KB
    libgcc-5.2.0               |                0         1.1 MB
    libgfortran-3.0.0          |                1         281 KB
    libxcb-1.12                |                0         1.5 MB
    mkl-11.3.3                 |                0       122.1 MB
    dbus-1.10.10               |                0         2.4 MB
    glib-2.43.0                |                1         5.4 MB
    libpng-1.6.22              |                0         214 KB
    libxml2-2.9.2              |                0         4.2 MB
    alabaster-0.7.9            |           py34_0          11 KB
    cython-0.24.1              |           py34_0         6.3 MB
    decorator-4.0.10           |           py34_0          12 KB
    docutils-0.12              |           py34_2         673 KB
    freetype-2.5.5             |                1         2.5 MB
    gstreamer-1.8.0            |                0         2.6 MB
    imagesize-0.7.1            |           py34_0           3 KB
    ipython_genutils-0.1.0     |           py34_0          33 KB
    markupsafe-0.23            |           py34_2          32 KB
    mpmath-0.19                |           py34_1         901 KB
    nose-1.3.7                 |           py34_1         196 KB
    numpy-1.11.1               |           py34_0         6.1 MB
    path.py-8.2.1              |           py34_0          47 KB
    ptyprocess-0.5.1           |           py34_0          19 KB
    pygments-2.1.3             |           py34_0         1.2 MB
    pyparsing-2.1.4            |           py34_0          72 KB
    pytz-2016.6.1              |           py34_0         177 KB
    pyyaml-3.12                |           py34_0         348 KB
    setuptools-27.2.0          |           py34_0         528 KB
    simplegeneric-0.8.1        |           py34_1           7 KB
    sip-4.18                   |           py34_0         240 KB
    six-1.10.0                 |           py34_0          17 KB
    snowballstemmer-1.2.1      |           py34_0          79 KB
    sphinx_rtd_theme-0.1.9     |           py34_0         628 KB
    wcwidth-0.1.7              |           py34_0          21 KB
    wheel-0.29.0               |           py34_0          82 KB
    babel-2.3.4                |           py34_0         4.8 MB
    cycler-0.10.0              |           py34_0          11 KB
    fontconfig-2.11.1          |                6         405 KB
    gst-plugins-base-1.8.0     |                0         3.1 MB
    jinja2-2.8                 |           py34_1         304 KB
    pexpect-4.0.1              |           py34_0          66 KB
    pickleshare-0.7.4          |           py34_0           9 KB
    pip-8.1.2                  |           py34_0         1.6 MB
    prompt_toolkit-1.0.3       |           py34_0         309 KB
    python-dateutil-2.5.3      |           py34_0         238 KB
    scipy-0.18.0               |      np111py34_0        30.7 MB
    sympy-1.0                  |           py34_0         5.9 MB
    traitlets-4.3.0            |           py34_0         125 KB
    ipython-5.1.0              |           py34_0         994 KB
    qt-5.6.0                   |                0        43.9 MB
    sphinx-1.4.1               |           py34_0         1.3 MB
    pyqt-5.6.0                 |           py34_0         5.2 MB
    matplotlib-1.5.3           |      np111py34_0         8.4 MB
    ------------------------------------------------------------
                                           Total:       279.6 MB
</code></pre></div>
<p dir="auto">This was not an issue when using matplotlib-1.5.1 and pyqt-4.11.4 (<a href="https://travis-ci.org/simpeg/simpeg/jobs/159897876#L379" rel="nofollow">https://travis-ci.org/simpeg/simpeg/jobs/159897876#L379</a>)</p>
<p dir="auto">Thanks for your help!</p>
<p dir="auto">Our pandas tests on travis started to fail last night on python 3.5 (eg <a href="https://travis-ci.org/pydata/pandas/jobs/160584906" rel="nofollow">https://travis-ci.org/pydata/pandas/jobs/160584906</a>) with errors in our plotting tests (among others: "ImportError: No module named 'PyQt4'").<br>
Compared to the previous build that passed, I noticed the difference in matplotlib and pyqt versions (matplotlib 1.5.1 -&gt; 1.5.3,  pyqt-4.11.4 -&gt; pyqt-5.6.0, qt-4.8.7 -&gt; qt-5.6.0). I could also reproduce this locally with <code class="notranslate">conda create -n test-mpl python=3.5 matplotlib -c defaults</code>, then importing matplotlib.pyplot gives the above error.</p>
<p dir="auto">I am not sure if this has anything to do with matplotlib itself, or rather a broken build in anaconda, but reporting it here to be sure.</p>