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

Make it possible to install ipython without nasty gui dependencies #2156

Closed
tomspur opened this issue Jul 17, 2012 · 14 comments
Closed

Make it possible to install ipython without nasty gui dependencies #2156

tomspur opened this issue Jul 17, 2012 · 14 comments
Milestone

Comments

@tomspur
Copy link
Contributor

tomspur commented Jul 17, 2012

Currently, when installing only the console/core part of ipython without installing IPython/frontend/qt/, which in turn requires PyQt4 to be installed, "ipython qtconsole" crashes with "ImportError: No module named qt.console.qtconsoleapp".
(Same for notebook and the tornado dependency.)

But as many users of ipython just want to install/use the console without wanting to be forced to install qt it would be great, to catch such a traceback properly.

Possible solutions:

  • Separately install "IPython/frontend/qt/" and catch the import failure of qt.console.qtconsoleapp.
  • Just try to import IPython.external.qt, catch there the "import qt" failure and ask the user to install Qt for proper functionality.

Or do you see another/better solution for such a case of unwanted dependencies?

@takluyver
Copy link
Member

To clarify: isn't the issue really "provide a better error message"? It's already perfectly possible to install and use IPython without Qt.

@tomspur
Copy link
Contributor Author

tomspur commented Jul 17, 2012

Without the Qt dependencies abrt will trigger a backtrace and users report the crash as error without seeing that they are missing PyQt4. So it will be "providing an error message instead of crashing", yes.

@bfroehle
Copy link
Contributor

The traceback is kind of long, but the message seems fine to me:

$ ./ipython qtconsole
Traceback (most recent call last):
  File "./ipython", line 10, in <module>
    launch_new_instance()
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 388, 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 313, 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 308, 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 420, 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 352, 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 56, in <module>
    from IPython.external.qt import QtCore, QtGui
  File "/usr/lib/python2.7/dist-packages/IPython/external/qt.py", line 43, in <module>
    raise ImportError('Cannot import PySide >= 1.0.3 or PyQt4 >= 4.7')
ImportError: Cannot import PySide >= 1.0.3 or PyQt4 >= 4.7

@bfroehle
Copy link
Contributor

@tomspur: I think your complaint lies more with whomever packaged up your version of IPython. For example, in the current Debian release the ipython script was modified to produce better error messages which correspond to the different ipython related packages.

from IPython.frontend.terminal.ipapp import launch_new_instance

try:
  launch_new_instance()
except ImportError as e:
  if "qt.console.qtconsoleapp" in e.message:
    print "Could not start qtconsole. Please install ipython-qtconsole"
  elif "html.notebook.notebookapp" in e.message:
    print "Could not start notebook. Please install ipython-notebook"
  else:
    # if there is no clue on the cause -- just re-raise
    raise

@tomspur
Copy link
Contributor Author

tomspur commented Jul 17, 2012

@bfroehle I'm currently updating Fedora for 0.13, but the snipped you provided would perfectly fit for Fedora too. Thanks.

The main reason for not doing downstream changes was to do the required changes upstream, so ipython will behave common on all platforms, if other distributions decide for the same splitting of the dependencies and this issue is meant to discuss about this case in general.

The only difference currently is that the "ipython-qtconsole" package is named "ipython-gui" over here, based on the dependency on wxpython some times ago.

@bfroehle
Copy link
Contributor

Since different distributions will split IPython differently, how do you suggest that we handle this upstream?

@tomspur
Copy link
Contributor Author

tomspur commented Jul 18, 2012

e.g. when you don't have ruby installed, %%ruby is not available, so how about printing a generic ipython qtconsole -> subcommand qtconsole doesn't exist or you need to install an extra package in your distribution. This will cover package splitting and typos like ipython qtconsol.

Or what is the usual practice for missing dependencies, e.g. when there is no python3-matplotlib? Currently there would be a crash, so I hesitate to provide an python3-ipython package at the moment...

@takluyver
Copy link
Member

It probably wouldn't cover misspellings like qtconsol, because that would be taken as a filename to run, so the message would become something like "file 'qtconsol' does not exist".

Matplotlib isn't a hard dependency for any frontend (for Debian packaging, ipython 'suggests' matplotlib). Trying to run with --pylab gives an ImportError, but doesn't actually crash. I'd encourage you to provide Python 3 packages - we have ipython3 packages for Debian & Ubuntu that now include -qtconsole and -notebook.

@fperez
Copy link
Member

fperez commented Jul 20, 2012

Furthermore, it seems to me that there isn't really anything we should/could be changing here. As you guys said above, given that each distro is free to split as it wishes and also names things differently, I'd rather the distros do what Debian did than us give a generic but invalid message, and one that would imply that there is a package manager that has the right dependencies to begin with.

People can be on such an old distro that their package manager doesn't have a valid dep, and they must therefore do everything from source (assuming no root access).

My vote is to close this as not being something really for us to fix.

@tomspur
Copy link
Contributor Author

tomspur commented Jul 20, 2012

Ok. I still don't like downstream patches, but will do so :)

Thanks.

@tomspur tomspur closed this as completed Jul 20, 2012
@fperez
Copy link
Member

fperez commented Jul 20, 2012

But the point here is: you want us to emit a message that says something about a 'distribution', but IPython can be installed outside of a distribution system (from source, by hand, on Solaris, on Windows, on AIX, etc).

So by definition this has to be something you do downstream, since it's only true for a linux distro, and the IPython we produce encompasses systems beyond linux distros.

@tomspur
Copy link
Contributor Author

tomspur commented Jul 20, 2012

I don't care that much to specifically tell the user which package (s)he needs to install. Searching for the missing command in the package manager is not really difficult. So a generic message like "Command not found, look if you have all the needed packages installed, provided in your distribution." would be fine for me.

So I want to not let ipython completely crash, in case there is such a split of the package, not say something specific about this 'distribution'.

@takluyver
Copy link
Member

If it's not going to run anyway, 'crashing' doesn't mean much, it's
just that the user sees a traceback, rather than a 1-line error
message

I think Fernando's point is that for us, an error message would have
to be so general that it wouldn't be useful. Distributions are better
placed to patch it with a meaningful error message.

@fperez
Copy link
Member

fperez commented Jul 20, 2012

I guess the only thing that would make sense would be to simply strip out the full tracebacks and replace them with

Import Error: no module named abcdd

The missing package above prevents IPython from starting, 
you need to install it for your platform.  See the official 
IPython documentation for platform-specific details.

Just so the user doesn't see all the internal frames. But that's about it...

@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

5 participants