Reputation: 702
The following simple example.py
code shows an ipython console with qt4 backend when run.
import sip
sip.setapi(u'QDate', 2)
sip.setapi(u'QDateTime', 2)
sip.setapi(u'QString', 2)
sip.setapi(u'QTextStream', 2)
sip.setapi(u'QTime', 2)
sip.setapi(u'QUrl', 2)
sip.setapi(u'QVariant', 2)
from PyQt4.QtGui import *
from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.inprocess import QtInProcessKernelManager
from IPython.lib import guisupport
class IPythonWidget(RichJupyterWidget):
def __init__(self, parent=None, **kwargs):
super(self.__class__, self).__init__(parent)
self.app = app = guisupport.get_app_qt4()
self.kernel_manager = kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
self.kernel = kernel = kernel_manager.kernel
kernel.gui = 'qt4'
self.kernel_client = kernel_client = kernel_manager.client()
kernel_client.start_channels()
if __name__ == '__main__':
app = QApplication([])
i = IPythonWidget()
i.show()
app.exec_()
However, executable generated by pyinstaller does not run. The debug output of exe file is as follows:
PyInstaller Bootloader 3.x
LOADER: executable is C:\Users\harshn\Desktop\dist\example\example.exe
LOADER: homepath is C:\Users\harshn\Desktop\dist\example
LOADER: _MEIPASS2 is NULL
LOADER: archivename is C:\Users\harshn\Desktop\dist\example\example.exe
LOADER: No need to extract files to run; setting extractionpath to homepath
LOADER: SetDllDirectory(C:\Users\harshn\Desktop\dist\example)
LOADER: Already in the child - running user's code.
LOADER: Python library: C:\Users\harshn\Desktop\dist\example\python27.dll
LOADER: Loaded functions from Python library.
LOADER: Manipulating environment (sys.path, sys.prefix)
LOADER: sys.prefix is C:\Users\harshn\Desktop\dist\example
LOADER: Setting runtime options
LOADER: Initializing python
LOADER: Overriding Python's sys.path
LOADER: Post-init sys.path is C:\Users\harshn\Desktop\dist\example
LOADER: Setting sys.argv
LOADER: setting sys._MEIPASS
LOADER: importing modules from CArchive
LOADER: extracted struct
LOADER: callfunction returned...
LOADER: extracted pyimod01_os_path
LOADER: callfunction returned...
LOADER: extracted pyimod02_archive
LOADER: callfunction returned...
LOADER: extracted pyimod03_importers
LOADER: callfunction returned...
LOADER: Installing PYZ archive with Python modules.
LOADER: PYZ archive: out00-PYZ.pyz
LOADER: Running pyiboot01_bootstrap.py
LOADER: Running pyi_rth_traitlets.py
LOADER: Running pyi_rth_pkgres.py
LOADER: Running pyi_rth_win32comgenpy.py
LOADER: Running pyi_rth_qt4plugins.py
Qt: Untested Windows version 10.0 detected!
LOADER: Running pyi_rth_mplconfig.py
LOADER: Running pyi_rth_mpldata.py
LOADER: Running pyi_rth__tkinter.py
LOADER: Running example.py
Traceback (most recent call last):
File "example.py", line 10, in <module>
File "C:\Users\harshn\Desktop\pyinstallerDev\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\qtconsole\rich_jupyter_widget.py", line 9, in <module>
File "C:\Users\harshn\Desktop\pyinstallerDev\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\qtconsole\qt.py", line 23, in <module>
File "site-packages\qtconsole\qt_loaders.py", line 309, in load_qt
ImportError:
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: 'pyqt'
PyQt4 installed: False
PyQt5 installed: False
PySide >= 1.0.3 installed: False
Tried to load: ['pyqt']
Failed to execute script example
LOADER: OK.
LOADER: Cleaning up Python interpreter.
Tried many things which I could possibly do from google search. Nothing seems to work. Any suggestion or help is highly appreciated. Thanks !
The following information may be helpful
Python: 2.7.11 (From Anaconda Python Distribution)
OS: Windows 10 (x64)
PyQt: Version 4.11.4
Pyinstaller Version: 3.2-48-ga00b13d
Upvotes: 1
Views: 540
Reputation: 1
I had the same problem. In uikit\ipython.py
, I was hitting the exception case here2.
try:
from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.inprocess import QtInProcessKernelManager
print "here 1"
except:
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget as RichJupyterWidget
from IPython.qt.inprocess import QtInProcessKernelManager
print "here 2"
I had to install qtconsole
and this resolved.
pip install qtconsole
Now the problem is getting pyinstaller to find all these parts. :-(
Upvotes: 0