简体   繁体   English

加载ipython qtconsole时出错

[英]Error loading ipython qtconsole

I need some advise here. 我需要一些建议。 I've installed ipython (sudo pip install ipython[all]) 我安装了ipython(sudo pip install ipython [all])

I've python 2.7, mac osx 10.9 64bits. 我有python 2.7,mac osx 10.9 64bits。

I'm trying to lunch qtconsole 我正在尝试午餐qtconsole

camilo-mbp:mvc cami$ ipython qtconsole
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
load_entry_point('ipython==2.2.0', 'console_scripts', 'ipython')()
File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 563, in   launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in  catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/terminal/ipapp.py", line 321, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in  catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/core/application.py", line 381, in initialize
self.parse_command_line(argv)
File "/Library/Python/2.7/site-packages/IPython/terminal/ipapp.py", line 316, in   parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in   catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 475, in   parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in  catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 406, in  initialize_subcommand
subapp = import_item(subapp)
File "/Library/Python/2.7/site-packages/IPython/utils/importstring.py", line 42, in import_item
module = __import__(package, fromlist=[obj])
File "/Library/Python/2.7/site-packages/IPython/qt/console/qtconsoleapp.py", line 58, in <module>
from IPython.external.qt import QtCore, QtGui
File "/Library/Python/2.7/site-packages/IPython/external/qt.py", line 23, in <module>
QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
File "/Library/Python/2.7/site-packages/IPython/external/qt_loaders.py", line 258, in load_qt
api_options))
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:   None
PyQt4 installed:                 False
PySide >= 1.0.3 installed:       False
Tried to load:                   ['pyside']

I've done the following command to set pyQt4 installed to True and is working ok 我已经完成以下命令将pyQt4安装为True并且正常工作

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

Now, I want to install pyside but a I've some errors: 现在,我想安装pyside,但我有一些错误:

camilo-mbp:mvc cami$ pip install pyside
Downloading/unpacking pyside
Downloading PySide-1.2.2.tar.gz (9.3MB): 9.3MB downloaded
Running setup.py egg_info for package pyside
Removing  /private/var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip_build_cami/pyside/pyside_package

package init file 'pyside_package/PySide/__init__.py' not found (or not a regular file)
package init file 'pyside_package/pysideuic/__init__.py' not found (or not a regular file)
warning: no previously-included files matching '**' found under directory 'sources/pyside-examples/examples/hyperui'
warning: no previously-included files matching '**' found under directory 'sources/pyside-examples/mobility'
warning: no previously-included files matching '**' found under directory 'sources/shiboken/.git'
warning: no previously-included files matching '**' found under directory 'sources/pyside/.git'
warning: no previously-included files matching '**' found under directory 'sources/pyside-tools/.git'
warning: no previously-included files matching '**' found under directory 'sources/pyside-examples/.git'
warning: no files found matching '**' under directory 'pyside_package/PySide'
warning: no files found matching '**' under directory 'pyside_package/PySide/docs'
warning: no files found matching '**' under directory 'pyside_package/PySide/plugins'
warning: no files found matching '**' under directory 'pyside_package/PySide/imports'
warning: no files found matching '**' under directory 'pyside_package/PySide/translations'
warning: no files found matching '**' under directory 'pyside_package/PySide/include'
warning: no files found matching '**' under directory 'pyside_package/PySide/typesystems'
warning: no files found matching '**' under directory 'pyside_package/PySide/examples'
warning: no files found matching '**' under directory 'pyside_package/pysideuic'
warning: no files found matching '**' under directory 'pyside_package/pysideuic/Compiler'
warning: no files found matching '**' under directory 'pyside_package/pysideuic/port_v2'
warning: no files found matching '**' under directory 'pyside_package/pysideuic/port_v3'
warning: no files found matching '**' under directory 'pyside_package/pysideuic/widget-plugins'
Installing collected packages: pyside
Running setup.py install for pyside
Removing /private/var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip_build_cami/pyside/pyside_package
Python architecture is 64bit
error: Failed to find cmake. Please specify the path to cmake with --cmake parameter.
Complete output from command    /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/private/var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip_build_cami/pyside/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip-AjpsAb-record/install-record.txt --single-version-externally-managed:
Removing /private/var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip_build_cami/pyside/pyside_package

running install

running build

Python architecture is 64bit

error: Failed to find cmake. Please specify the path to cmake with --cmake parameter.

----------------------------------------
Cleaning up...
Command       /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -  c "import   setuptools;__file__='/private/var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip_build_cami/pyside/s     etup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --  record /var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip-AjpsAb-record/install-record.txt --  single-version-externally-managed failed with error code 1 in   /private/var/folders/y3/xwgxtgzs27z5mwzhpmw244d00000gp/T/pip_build_cami/pyside
Storing complete log in /Users/cami/Library/Logs/pip.log

I tried to install cmake 我试着安装cmake

camilo-mbp:mvc cami$ pip install cmake
Downloading/unpacking cmake
Could not find any downloads that satisfy the requirement cmake
Cleaning up...
No distributions at all found for cmake
Storing complete log in /Users/cami/Library/Logs/pip.log
camilo-mbp:mvc cami$ 

What else should I do ? 我还该怎么办?

Thanks in advance 提前致谢

Since I know, cmake is not a python package. 因为我知道,cmake不是python包。 It is a build tool. 它是一个构建工具。 So, all you have to do is install it. 所以,你所要做的就是安装它。 You can get it from here: CMake site 你可以从这里得到它: CMake网站

Also, you should check if the Apple development tools does have cmake already. 此外,您应该检查Apple开发工具是否已经拥有cmake。

有关在MacOSX上构建和安装PySide的文档,请访问http://pyside.readthedocs.org/en/latest/building/macosx.html

Problem statement Qtconsole import error or conflict. 问题陈述Qtconsole导入错误或冲突。

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. 你可以深入了解uikit / ipython.py并看到有一个try catch块围绕导入新旧库及以下内容。

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. 步骤1)我开始在python提示下手动运行东西,我确信自己已正确安装qt.console。 If you find you can not do this. 如果你发现你不能这样做。 Install the missing module. 安装缺少的模块。

pip install qtconsole pip install qtconsole

Step 2) if you are using pyqt4 make sure you exclude pyqt5, pyside, and pyside2 modules in your pyinstaller spec file. 步骤2)如果您使用pyqt4,请确保在pyinstaller规范文件中排除pyqt5,pyside和pyside2模块。 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. Step3)我将首先告诉你解决方案然后如何到达那里。 The problem was that pyinstaller was putting my pyqt4 executables at the top level in the package. 问题是pyinstaller将我的pyqt4可执行文件放在包中的顶层。 Qtconsole was looking for them in a PyQt4 directory. Qtconsole正在PyQt4目录中查找它们。 The following goes in the exe section of your spec file. 以下是spec文件的exe部分。

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') ], /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. 这就是我进入第3步的方式。我认为这部分很重要。 I added this to my spec file just for development, not for the customer's package. 我将此添加到我的spec文件中仅用于开发,而不是用于客户的包。 The problem with developing the package was it was failing to run and then the tmp/ directory would remove itself. 开发包的问题是它无法运行,然后tmp /目录将自行删除。 I couldn't see what the problem was. 我看不出有什么问题。 I knew I had pyqt4 installed and that the application ran by hand. 我知道我安装了pyqt4并且应用程序是手动运行的。 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. 快乐的小道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM