Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if pyside partially present ipython qtconsole fails to load even if pyqt4 present #2566

Closed
jamadagni opened this issue Nov 11, 2012 · 2 comments
Milestone

Comments

@jamadagni
Copy link

On my Kubuntu Precise system I had installed python-pyside.qtcore and python-pyside.qtgui (but not pyside.qtsvg) for running another PySide-based program. Kubuntu of course has python-qt4 by default. In this setup, I found that running ipython qtconsole fails with the following error message:

$ ipython qtconsole
Traceback (most recent call last):
  File "/usr/bin/ipython", line 8, in <module>
    launch_new_instance()
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 402, in launch_new_instance
    app.initialize()
  File "<string>", line 2, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 302, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<string>", line 2, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/core/application.py", line 325, in initialize
    self.parse_command_line(argv)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 297, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<string>", line 2, in parse_command_line
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 413, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<string>", line 2, in initialize_subcommand
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 349, in initialize_subcommand
    subapp = import_item(subapp)
  File "/usr/lib/python2.7/dist-packages/IPython/utils/importstring.py", line 40, in import_item
    module = __import__(package,fromlist=[obj])
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/qtconsoleapp.py", line 30, in <module>
    from IPython.external.qt import QtCore, QtGui
  File "/usr/lib/python2.7/dist-packages/IPython/external/qt.py", line 62, in <module>
    from PySide import QtCore, QtGui, QtSvg
ImportError: cannot import name QtSvg

What happens is as follows. In IPython/external/qt.py, line 24

QT_API = os.environ.get('QT_API')

gets set to a null string because there is no QT_API environment variable on my system, and the code then proceeds to line 27:

import PySide

which does not raise an ImportError because pyside.qtcore|qtgui are installed on my system, and hence line 31 is executed:

QT_API = QT_API_PYSIDE

which however later on leads to line 62:

from PySide import QtCore, QtGui, QtSvg

being executed which however does not work because the python-pyside.qtsvg package was not installed on my system.

I cannot fault the Debian packaging because as you can see on http://packages.debian.org/sid/ipython-qtconsole or http://packages.ubuntu.com/precise/ipython-qtconsole they do list a dependency on pyside.qtsvg but only if python-qt4 is not installed (which it is).

The solution would be to test for PySide having all the required modules before determining it as the appropriate Qt bindings. I propose the following patch for qt.py:

--- qt.py.orig  2012-04-22 10:40:27.000000000 +0530
+++ qt.py       2012-11-11 19:20:43.444954428 +0530
@@ -30,2 +30,3 @@
             raise ImportError
+        from PySide import QtCore, QtGui, QtSvg # checking that all required PySide modules are available 
         QT_API = QT_API_PYSIDE
@@ -35,3 +36,3 @@
             import PyQt4
-            from PyQt4 import QtCore
+            from PyQt4 import QtCore, QtGui, QtSvg # checking that all required PyQt4 modules are available
             if QtCore.PYQT_VERSION_STR < '4.7':
@@ -41,3 +42,3 @@
         except ImportError:
-            raise ImportError('Cannot import PySide >= 1.0.3 or PyQt4 >= 4.7')
+            raise ImportError('IPython requires QtCore, QtGui and QtSvg modules of either PySide >= 1.0.3 or PyQt4 >= 4.7')

but for some reason on my system modifying /usr/share/pyshared/IPython/external/qt.py thus gives the error:

$ ipython qtconsole
python: /build/buildd/sip4-4.13.2/siplib/siplib.c:7915: sip_api_can_convert_to_type: Assertion `(((td)->td_flags & 0x0007) == 0x0000) || (((td)->td_flags & 0x0007) == 0x0002)' failed.
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-17799.json
Aborted (core dumped)

... so I leave it to the developers to fix this appropriately.

@takluyver
Copy link
Member

I think this should already have been fixed, see 19502ae. The fix probably isn't in the version packaged in precise, though. If you want to use a newer version, you can add this PPA: https://launchpad.net/~jtaylor/+archive/ipython

I'll close this issue on the grounds that it's already fixed - if you can reproduce the problem with 0.13.1, we can reopen it

@juliantaylor
Copy link
Contributor

see also gh-1431

@minrk minrk added this to the no action milestone Mar 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants