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

Plotting is not working in the console for Ipython 0.11 and 0.12dev #743

Closed
spyder-bot opened this issue Feb 17, 2015 · 10 comments
Closed

Comments

@spyder-bot
Copy link
Collaborator

From ccordoba12 on 2011-08-30T21:31:57Z

If you enter something like:

In [1]: %pylab

Welcome to pylab, a matplotlib-based Python environment [backend: Qt4Agg].
For more information, type 'help(pylab)'.

In [2]: plot(range(100))
Out[2]: [<matplotlib.lines.Line2D at 0x2d85150>]

there isn't any window opened. This is true for Mac and Linux and with all the matplotlib backends available.

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=743

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-09-02T01:38:04Z

The more I think about it (and the more I spend time on it), the more I doubt that there will ever be a decent support of IPython >=v0.11 in Spyder's console. That's why I have fixed the PyQt input hook issue on Windows platforms: now the standard Python interpreter may be used even on Windows to do interactive plotting.

Plus, I've introduced some basic special commands in the standard Python interpreter: https://code.google.com/p/spyderlib/source/detail?r=07394d8b179087e8be2f6a629e096ed3c4c4c14e And fixed a bug with PYTHONSTARTUP substitution: https://code.google.com/p/spyderlib/source/detail?r=2d7929020f3e7756dfc4456d5653fda66759c3c9 These two changesets were intended to facilitate the use of standard Python interpreter as an interactive computing shell. I've created two PYTHONSTARTUP scripts (on my machine) which are basically:

#guiqwt-interactive
from numpy import *
from guiqwt.pyplot import *
ion()

and:

#matplotlib-interactive
from pylab import *
ion()

With these startup scripts, I have my own IPython (not as powerful as IPython, of course).

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-09-04T06:07:54Z

Status: Duplicate
Mergedinto: 727

@spyder-bot
Copy link
Collaborator Author

From DavidAnt...@gmail.com on 2011-09-06T16:10:23Z

I'm a bit puzzled by what the problem is here. I'm running ipython 0.12dev (thanks to Pierre's suggestion of putting it's source in my PYTHONPATH). If I type in the following into an IPython shell:

import matplotlib.pyplot as plt
plt.figure()
plt.plot(range(10))
plt.show()

I get a popup figure as expected, although it does block the terminal. I'm running the latest hg version of spyder on ubuntu 10.04.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2011-09-06T18:11:56Z

You're right David, but that's one of the selling points of Ipython: not to block the console, so you can do plots and continue exploring your namespace.

But even worst is that my first example don't show anything.

@spyder-bot
Copy link
Collaborator Author

From DavidAnt...@gmail.com on 2011-09-06T23:21:02Z

Pierre, are you able to elaborate on the major show-stoppers for integrating Ipython >= 0.11 into the console? I presume it has something to do with Ipython's zeromq based parallelism not cooperating well with spyder's Qt-based threads.

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-09-07T02:08:14Z

Actually it's more likely related to the new "input hooks" machinery. These are based on PyOS_InputHook - which is a good thing when using IPython from a terminal, but this is not working when running IPython from a subprocess like within Spyder's console (I did not have the opportunity to do some tests on Linux though).

The problem may be coming from Python itself because I'm unable to install a PyOS_InputHook function even when I'm using the InteractiveConsole (from the builtin module 'console').

Here is my test script:

from spyderlib.widgets.externalshell.inputhook import manager
manager.install_qt_inputhook()
import code
console = code.InteractiveConsole()
console.interact()

To check if the input hook has been installed, just add print "." (for example) at the beginning of the input hook function qt_inputhook.
When I run this test script outside Spyder, it works: the input hook is executed at each new prompt. On the contrary, inside Spyder, the input hook is never called.

I'm convinced that if we make it work with the test script above, it will work with IPython because IPython is no more than an improved 'InteractiveConsole'. It works the same way.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2011-09-09T08:15:24Z

Pierre, after your latest change (i.e. rev 7070db5139a2) I saw you removed externalshell/inputhook.py. How can we test this now?

A few more comments:

  1. I tested your script on Linux before the change and it wasn't working for me. It give me a prompt but when I tried to evaluate anything, it did nothing and the prompt never came back.
  2. After the change runfile and debugfile are working on Linux (before they weren't) but the console is now blocked when you call show() after a plot.
  3. After a couple of hours of thought and wandering trough the IPython code, I think we are trying to go in the wrong direction. IPython is not meant now to be embedded in GUI's as before. Now you have create a frontend that connects to a running kernel, even to get a "terminal IPython", because the kernel is the one in charge of handling the inputhook and matplotlib interaction. So I would suggest to take a look at the code in: Two-process terminal frontend ipython/ipython#708 which is a two-process terminal frontend. Maybe we could use it to deliver a perfectly working Ipython console.

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-09-09T10:27:30Z

Carlos,

  1. -> It doesn't surprise me if this script was not working as is on Linux. The qt input hook was not aimed at Linux platforms as PyQt input hook is working well on those platforms.
  2. -> Again, the "Replace PyQt's input hook by Spyder's" should not be used on Linux. At least not in its current implementation. I would really need to do some tests on Linux but I was trying to make it work on Windows first.
  3. -> The right way to integrate IPython in Spyder is this way I think: https://code.google.com/p/spyderlib/issues/detail?id=726&colspec=ID%20Cat%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&start=100 http://spyder-ide.blogspot.com/2011/08/preview-of-new-ipython-plugin-for.html If we try to embed the two-process terminal frontend within Spyder, we will probably reimplement the IPython Qt console in the end... so I think the future of IPython/Spyder integration will require to work with IPython development team in order to eventually adapt the Qt console interface and fully integrate it within Spyder.

The goal of this "simple" integration within Spyder's console was to continue using it without changing anything (or with little changes). But we must keep in mind that the fact that IPython v0.10 was working within Spyder's console was almost a miracle according to the IPython dev team... so it's not so surprising that we have serious problems integrating v0.11 the same way.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2011-09-10T10:40:43Z

Pierre,

  1. & 2. If PyQt input hook is working well on Linux, then wouldn't it be better to hide/disable "Replace PyQt's input hook by Spyder's" in these platforms?
  2. I didn't want to imply that Qt console is not the future for Spyder's IPython integration. With my (perhaps unfortunate) words "wrong direction" I meant to try to replace/override IPython input hook (instead of using a two-process terminal) because I find it hackish and a bit hard to achieve.

But of course this will break the idea of "simple" integration because then all monitor code will have to be rewritten. I noticed this yesterday when I embedded the two-process terminal I talked you about in Spyder. I can confirm that plotting is working fine with it, but all the rest is broken :)

By the way, your superb (and I didn't know miraculous) IPython integration in Spyder is what moved me to use it and then to contribute to it. It was the best IPython GUI integration until 0.11.

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-09-11T02:29:36Z

(Maybe we should have opened a discussion on Spyder's Google Group after all...!)

Carlos,

  1. & 2.: You're perfectly right: we should disable and hide this option on non-Windows platforms

3.: Actually, I didn't try the code you were referring to but if this is a zmq two-process terminal, then we will be confronted to the same issues as the IPython plugin (note that it already supports the Variable explorer).

Regarding the IPython v0.10 integration, this was one of the most spectacular new feature of Spyder v2.0. Spyder v1 interactive console was running in the same process, same thread as Spyder's main window, an unsafe architecture. IPython integration was, at that time, the only way to provide interactivity (non-blocking GUI support in console) with a safer architecture. Now, the standard Python can provide such interactivity and safety ( http://spyder-ide.blogspot.com/2011/09/new-enhanced-scientific-python.html ).
Anyway, I think the priority is to provide MATLAB-like features for regular users without forcing them to either install IPython or downgrade IPython to v0.10 or upgrade it to v0.12dev, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants