1

次の簡単なexample.pyコードは、実行時の qt4 バックエンドを備えた ipython コンソールを示しています。

    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_()

example.py の出力

ただし、pyinstaller によって生成された実行可能ファイルは実行されません。exe ファイルのデバッグ出力は次のとおりです。

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.

Google検索からできる可能性のある多くのことを試しました。何も機能していないようです。どんな提案や助けも大歓迎です。ありがとう !

次の情報が役立つ場合があります

Python: 2.7.11 (From Anaconda Python Distribution)
OS: Windows 10 (x64)
PyQt: Version 4.11.4
Pyinstaller Version: 3.2-48-ga00b13d
4

1 に答える 1