python - Import Error embedding IPython into PyQt application -
i have functioning pyqt4 based application trying embed ipython console use kind of scripting environment.
i've adapted example ipython's github page fit application's module system. however, if any pyqt import happens before ipython imports
from ipython.qt.console.rich_ipython_widget import richipythonwidget ipython.qt.inprocess import qtinprocesskernelmanager i following error:
importerror: not load requested qt binding. please ensure pyqt4 >= 4.7 or pyside >= 1.0.3 available, , 1 imported per session. currently-imported qt library: 'pyqtv1' pyqt4 installed: true pyside >= 1.0.3 installed: false tried load: ['pyside', 'pyqt'] i've traced error ipython's qt module, forcing 'pyqtv1' loaded (by replacing api_opts = [qt_api] api_opts = ['pyqtv1'] breaks qstring inside ipython window.
however, if make imports happen first (by importing module code in before else), error goes away , breaks qstring importerror: cannot import name qstring.
i've verified if make self-contained qapplication in module contains ipython instance, making sure import pyqt.qtgui after doing ipython imports, works ask expected. it's when try , mix ipython code other pyqt code things break.
any suggestions how fix error?
i'm on ubuntu linux 12.04, , ipython version 2.0.0-dev pulled on march 10th.
pyqt offers 2 different apis strings: can choose 1 use code this:
import sip sip.setapi('qstring', 2) pyqt4 import qtgui once import pyqt4, api set , cannot changed. on python 2, defaults version 1 backwards compatibility, ipython requires api version 2. version 2 default on python 3, , pyside's api equivalent version 2.
if you've used v1 api in application, cannot use ipython qt console embedded in application, except porting v2 api. however, can embed ipython kernel in application, , connect qt console in separate process.
Comments
Post a Comment