Error loading ipython qtconsole

别来无恙 提交于 2019-12-04 10:44:23

Since I know, cmake is not a python package. It is a build tool. So, all you have to do is install it. You can get it from here: CMake site

Also, you should check if the Apple development tools does have cmake already.

The documentation about building and installing PySide on MacOSX is here http://pyside.readthedocs.org/en/latest/building/macosx.html

Problem statement Qtconsole import error or conflict.

This is the exact error message I was getting

File "uikit/ipython.py", line 5, in <module>
ImportError: No module named qt.console.rich_ipython_widget
[28603] Failed to execute script bosetap

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

you can dig into uikit/ipython.py and see there is an try catch block around the import of new vs old libraries and the following.

QT_API = os.environ.get('QT_API', None)
if QT_API not in [QT_API_PYSIDE, QT_API_PYSIDE2, QT_API_PYQT, QT_API_PYQT5, None]:
raise RuntimeError("Invalid Qt API %r, valid values are: %r, %r, %r, %r" %
(QT_API, QT_API_PYSIDE, QT_API_PYSIDE2, QT_API_PYQT, QT_API_PYQT5))
if QT_API is None:
api_opts = [QT_API_PYQT5, QT_API_PYSIDE2, QT_API_PYSIDE, QT_API_PYQT]
else:
api_opts = [QT_API]

step 1) I started running things by hand at a python prompt and I convinced myself that qt.console was installed correctly. If you find you can not do this. Install the missing module.

pip install qtconsole

Step 2) if you are using pyqt4 make sure you exclude pyqt5, pyside, and pyside2 modules in your pyinstaller spec file. It might look something like this. This goes in the analysis section

excludes=['pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5',
                'pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5',
                'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5',
                'pyqtgraph.GraphicsScene.exportDialogTemplate_pyqt5',
                'PyQt5',' PyQt5.QtCore','PyQt5.QtGui','PyQt5.QtPrintSupport',
                'PyQt5.QtSvg','PySide','PySide2'],

This might have been overkill. Once I got it working, I didn’t want to touch it. The optimization is left as an exercise for the reader.

Step3) I’m going to tell you the solution first and then how to get there. The problem was that pyinstaller was putting my pyqt4 executables at the top level in the package. Qtconsole was looking for them in a PyQt4 directory. The following goes in the exe section of your spec file.

a.binaries + [('PyQt4/QtCore.so','/usr/lib/python2.7/dist-packages
  PyQt/QtCore.so','BINARY'), ('PyQt4/QtGui.so','/usr/lib/python2.7/dist-packages
/PyQt4/QtGui.so','BINARY'), ('PyQt4/QtOpenGL.so','/usr/lib/python2.7/dist-packages 
/PyQt4/QtOpenGL.so','BINARY'), ('PyQt4/QtSvg.so','/usr/lib/python2.7/dist-packages
/PyQt4/QtSvg.so','BINARY'), ('PyQt4/QtTest.so','/usr/lib/python2.7/dist-packages
/PyQt4/QtTest.so','BINARY'), ('PyQt4/QtXml.so','/usr/lib/python2.7/dist-packages

/PyQt4/QtXml.so','BINARY') ],

So, the bad part about this solution is we now get warnings that we have the same executable in two places. The optimization is left as an exercise for the reader. Honestly, I haven’t figured out how to resolve this yet. So, if you do… it would be nice to hear from you. This is how I got to step 3. I think this part is important. I added this to my spec file just for development, not for the customer’s package. The problem with developing the package was it was failing to run and then the tmp/ directory would remove itself. I couldn’t see what the problem was. I knew I had pyqt4 installed and that the application ran by hand. It was very frustrating. So, if you do the below to your spec file you will get a directory built instead of an executable. That directory stays and you can peak inside and see what is going on. Then, you are armed and dangerous to enable the solution. Then when you have it working, you revert this to develop an executable for your customer.

  exe = EXE(pyz,
              a.scripts,
             [],
              exclude_binaries=True,
              name='bosetap',
              debug=False,
              bootloader_ignore_signals=False,
              strip=False,
              upx=True,
              console=True )

    coll = COLLECT(exe,
                   a.binaries,
                   a.zipfiles,
                   a.datas,
                   strip=False,
                   upx=True,
                   name='bosetap')

Special thanks to my boss as I banged my head against this for 1 week. Happy Trails.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!