If I understand your mail correct, you are reporting two problems here.
1) show() locks the progression of the script until it is closed again.
This behaviour is kind of expected I believe. Although I am not a
developer and I don't grasp the full complexity of this problem, I don't
believe the cause lies with Spyder but with some inherent Python
characteristics combined with how the plotting backend is functioning. A
few days ago I tried to look into the problem a little further and my
conclusions can be found in following thread on this list:
http://groups.google.com/group/spyderlib/browse_thread/thread/4a47ca60ebf0ace2.
In short mu conclusions: when generating lots of plots in a single
script, don't use interactive plotting but save you pictures as they are
generated and watch them in either .png, .jpg. eps or other formats
(that's how I work).
If show() works and it results in a figure, I think the interactive mode
is already active (see
http://matplotlib.sourceforge.net/users/shell.html). Have you also tried
additional draw() statements? That will force matplotlib to redraw the
figure. It could be that some plotting commands did not trigger the
draw() command so they haven't made it yet to the interactive figure. As
far as I understand the interactive mode, the only difference is that is
should automatically trigger some draw() statements after each update of
the plot.
Since there is more to discover of how to deal with this interactive
plotting issue correctly, you can't consider my answer as final. For
instance, just found this:
http://scipy.org/Cookbook/Matplotlib/Interactive_Plotting. I will need
more time to dig in deeper and also raise this matter on the matplotlib
develop/user lists.
Please correct me if I am wrong on this whole interactive plotting story!
2) "ValueError: API 'QString": sorry, I am not much of a help here.
And now, back to my "real" work. To be continued...
Regards,
David
thanks for your response, but the behavior of ipython is far from what
is (or I) expected. If I compare the ipython console inside spyder it
behaves different from what ipython does when I start it from shell. So
spyder (or how spyder calls ipython) is the difference and renders using
spyder infeasible for me (at least on linux, works nicely on win).
The following code is an example:
# -*- coding: utf-8 -*-
# *** Spyder Python Console History Log ***
##---(Wed Mar 7 15:56:30 2012)---
import matplotlib.pyplot as plt
import numpy as np
plt.plot(np.arange(10))
plt.draw()
in the spyder ipython console, nothing happens while in the spyder
python console a window opens with the plot. When I run
plt.show()
in ipython a window opens with the plot but the console is locked. When
I then close the window and run
plt.interactive(True)
plt.plot(np.arange(10))
plt.draw()
Nothing happens. When I run
plt.show()
nothing happens. When I run
plt.figure()
nothing happens, not even a blank window opens. When I run
plt.interactive(False)
The old behavior with the lock is back. So spyder is calling ipython
with some weird command line parameters. Because when I look at sys.argv
(the argument list) it's
In [1]: sys.argv
Out[1]:
['/usr/local/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/startup.py',
'-pylab',
'-q4thread',
'-colors',
'LightBG',
'-xmode',
'Plain']
which must be wrong because that's not a valid ipython v0.12 argument
list. When I try to call ipython from shell with this list, I get
WARNING: `-pylab` flag has been deprecated.
Use `--pylab` instead, or `--pylab=foo` to specify a backend.=========
[...]
[TerminalIPythonApp] Bad config encountered during initialization:
[TerminalIPythonApp] Unrecognized flag: '-q4thread'
And the list of loaded modules is also strange:
In [1]: whos
Variable Type Data/Info
--------------------------------------------------
InteractiveShellEmbed MetaHasTraits <class
'IPython.frontend.<...>d.InteractiveShellEmbed'>
h5py module <module 'h5py' from
'/usr<...>kages/h5py/__init__.pyc'>
os module <module 'os' from
'/usr/lib/python2.7/os.pyc'>
osp module <module 'posixpath' from
<...>python2.7/posixpath.pyc'>
sys module <module 'sys' (built-in)>
However, when I try to load matplotlib and set the backend, I get an
error because the backend is already set to Qt4Agg.
In [3]: mlib.use('TkAgg')
UserWarning: This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
So somewhere during the initialization of ipython matplotlib has been
loaded, (mis-)configured, and unloaded so that I cannot configure it. I
can change this by disabling matplotlib in the preferences, but
whichever backend I load manually won't work.
It seems to me that spyder ignores the parameters set in the "External
Modules" tab of the console options in the preferences. Because even if
I enter an invalid statement in the "IPython interpreter command line
options" field nothing changes (and the default value does not at all
correspond to what sys.argv says after loading).
I checked on 2 different computers, both running spyder 2.1.8 but one
with ipython 0.10 and the other with 0.12. The 0.10 works flawlessly, it
even reads my .ipython folder and loads the config files, while the 0.12
has the above mentioned bugs. However, downgrading is not an option for me.
So who knows where the misconfiguration happens and where to fix it?
Cheers
Philipp
Thanks for your detailed explanation. As you've already noticed, our
support for Ipython 0.12 is quite poor. They changed a lot of things and
we haven't had time to catch up, in part because our support for ipython
0.10 is quite good and we haven't needed it.
I have good and bad news for you:
The bad ones first: plotting doesn't work in the ipython console for any
version >= 0.11, sorry. I'll try to look into this to see if I can make
it work again without loosing all our other features (like code
completion). Don't wait it though until Spyder 2.2.
The good ones: I discovered a fix to the "ValueError: API 'QString' has
already been set to version 1". It lied in something the Ipython guys
changed between versions 0.11 and 0.12. This fix will be in 2.1.9
Cheers,
Carlos
El 07/03/12 10:55, Philipp Lies escribió:
thanks for your explanation. Looking forward to 2.1.9 then! Thanks and keep up the awesome work that spyder is!
Philipp
On 08.03.2012 00:43, Carlos C�rdoba wrote:
> Hi Philipp,
>
> Thanks for your detailed explanation. As you've already noticed, our support for Ipython 0.12 is quite poor. They changed a lot of things and we haven't had time to catch up, in part because our support for ipython 0.10 is quite good and we haven't needed it.
>
> I have good and bad news for you:
>
> The bad ones first: plotting doesn't work in the ipython console for any version >= 0.11, sorry. I'll try to look into this to see if I can make it work again without loosing all our other features (like code completion). Don't wait it though until Spyder 2.2.
>
> The good ones: I discovered a fix to the "ValueError: API 'QString' has already been set to version 1". It lied in something the Ipython guys changed between versions 0.11 and 0.12. This fix will be in 2.1.9
>
> Cheers,
> Carlos
>
> El 07/03/12 10:55, Philipp Lies escribi�:
Thanks for the extensive response. Seems that I have a lot more to learn
on the IPython/Spyder department. You got a lot further than my futile
attempts :-)
Regards,
David
FYI, IPython 0.12 is now working with Spyder's latest Mercurial
changesets (meaning that both v2.1.9 and v2.2.0 will support recent
IPython versions again).
Note that IPython 0.11+ support is still experimental -- and it's only
working in the IPython plugin (*not* in the Console plugin). The
Console plugin supports only IPython 0.10 and I doubt that we will
ever be able to add support for IPython 0.11+
(http://spyder-ide.blogspot.fr/2011/09/no-ipython-v011-support-in-spyders.html).
Cheers,
Pierre
> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To post to this group, send email to spyd...@googlegroups.com.
> To unsubscribe from this group, send email to
> spyderlib+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/spyderlib?hl=en.
>
The ipython plugin starts nicely with both PySide and PyQt API, however,
plotting has some strange behaviors:
I can open only exactly 1 ipython frontend. Whenever I try to open a
second one, I get
[IPythonApp] Could not find existing kernel connection file
kernel-17160.json
(or any other kernel-xxx.json, once it even showed kernel*-json)
Further, when I try to open a window (e.g. using figure()) with PySide I
get the following:
TypeError: QWidget.setFocusPolicy(Qt.FocusPolicy): argument 1 has
unexpected type 'PySide.QtCore.Qt.FocusPolicy'
For PyQT, the window opens when I set matplotlib.interactive(False) but
then the console is locked. The window doesn't open/update when
interactive is True. So plotting is unusable.
The ipython frontend uses window based plotting even though I have
specified to use pylab inline in the Preferences which is ignored
completely.
I further have the strange bug that sometime when I start spyder the
upper options in the Interpreters menu (start console, start ipython
console, start ipython kernel) are grayed out, only the "start new
frontend" entry is available.
However, what works for me is opening an ipython session outside of
spyder with
ipython qtconsole --pylab=inline
and then just open one frontend to the existing kernel with spyder. Running
ipython kernel --pylab=inline
does not work and produces the same errors as running a kernel inside of
spyder (ignores pylab=inline option and tries to open windows)
Hope this feedback helps!
Cheers
Philipp
On 03/19/2012 10:28 PM, Pierre Raybaut wrote:
> Hi all,
>
> FYI, IPython 0.12 is now working with Spyder's latest Mercurial
> changesets (meaning that both v2.1.9 and v2.2.0 will support recent
> IPython versions again).
>
> Note that IPython 0.11+ support is still experimental -- and it's only
> working in the IPython plugin (*not* in the Console plugin). The
> Console plugin supports only IPython 0.10 and I doubt that we will
> ever be able to add support for IPython 0.11+
> (http://spyder-ide.blogspot.fr/2011/09/no-ipython-v011-support-in-spyders.html).
>
> Cheers,
> Pierre
>
> Le 8 mars 2012 11:21, David Verelst <david....@gmail.com> a �crit :
-Pierre
> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/spyderlib/-/Y4kjcX_dL-YJ.
I've just fixed a couple of bugs including the multiple instances issue.
Please try again and keep me informed.
HTH,
-Pierre