I have a fully functioning PyQt4 based application that I am now trying to embed an IPython console into for use as a kind of scripting environment.
I've roughly adapted the example from IPython's Github page to fit into my application's module system. However, if any PyQt import happens before the IPython imports
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.qt.inprocess import QtInProcessKernelManager
I get the following error:
ImportError:
Could not load requested Qt binding. Please ensure that
PyQt4 >= 4.7 or PySide >= 1.0.3 is available,
and only one is imported per session.
Currently-imported Qt library: 'pyqtv1'
PyQt4 installed: True
PySide >= 1.0.3 installed: False
Tried to load: ['pyside', 'pyqt']
I've traced this error to IPython's
qt
module, but essentially forcing 'pyqtv1' to be loaded (by replacing api_opts = [QT_API]
with api_opts = ['pyqtv1']
breaks QString
inside the IPython
window.
However, if I make it so that those imports happen first (by importing the module this code is in before anything else), that error goes away and it basically breaks QString
completely with an ImportError: cannot import name QString
.
I've verified that if I make a self-contained QApplication
in the module that contains the IPython instance, making sure to import PyQt.QtGui
after doing the IPython
imports, it works ask expected. It's only when I try and mix the IPython
code with any other PyQt
code that things break.
Any suggestions as to how to fix the error?
I'm on Ubuntu Linux 12.04, and IPython is version 2.0.0-dev pulled on March 10th.