I really want to switch to Python 3, but Ubuntu 14.04 makes it difficult to do so when using the IPython+pylab framework.

My settings: I have installed most of the important packages using pip rather than aptitude. Thes packages include numpy 1.10.1, scipy 0.16.1, matplotlib 1.5.0, pylab 0.1.0 and IPython 4.0.1.

I have also installed python3-pyqt5 5.2.1 and python3-pyside 1.2.1 using aptitude.

Using matplotlib from within IPython works well:

import matplotlib.pyplot as plt
plt.plot([0, 1], [1, 2])

But the problem starts when I try to use pylab, either by calling ipython --pylab or by calling pylab from within IPython. This is what I get in both of these cases:

    Could not load requested Qt binding. Please ensure that
    PyQt4 >= 4.7, PyQt5 or PySide >= 1.0.3 is available,
    and only one is imported per session.

    Currently-imported Qt library:   'pyqt5'
    PyQt4 installed:                 False
    PyQt5 installed:                 False
    PySide >= 1.0.3 installed:       True
    Tried to load:                   ['pyqt5']

So, if I understand it properly, it does not recognize that PyQt5 is installed. This is weird for two reasons; first, import PyQt5 and import PyQt5.QtCore both don't complain. The second reason is that a second call to pylab works perfectly, and with Qt5!

Using matplotlib backend: Qt5Agg
Populating the interactive namespace from numpy and matplotlib

However, there's another consequence for this. After plotting, successfully (say, with plot([0, 1], [1, 2])), when I exit IPython using Ctrl-D, I get a Segmentation fault (core dumped).

This is a problem I have for about 3 months now. I have already posted a couple of questions here: Really installing PyQt4/5 for python 3.4 on trusty and https://stackoverflow.com/questions/32007733/pip-install-pyside-fails. I have tried probably almost all combinations of installing pyside/pyqt5/numpy/scipy/matplotlib/ipython/pylab via pip/aptitude. Nothing seems to work properly.


On Ubuntu 14.04, I could start ipython and then import PyQt5, but if I run ipython --matplotlib qt5, it states pyqt5 is not installed.

I then looked into the code and saw in the file /usr/local/lib/python3.4/dist-packages/IPython/external/qt_loaders.py, that ipython checks for QtCore, QtGui, Qtsvg and in the case of pyqt5 also for qtwidgets. Naturally, I did have QtCore, QtGui and QtWidgets installed, but not Qtsvg. I ran synaptic and installed Qtsvg for pyqt5 (that is python3-pyqt5.qtsvg). Now it works.

TL;DR: Install the python3-pyqt5.qtsvg package:

sudo apt-get install python3-pyqt5.qtsvg
|improve this answer|||||
  • Loving you for that pointer, thanks! The error message should really be more specific. – Jan-Philip Gehrcke Dec 28 '15 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.