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ó:
Hi,
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
On 03/06/2012 10:37 AM, David Verelst wrote:
Hi,
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
On 05/03/12 15:16, Philipp Lies wrote:
Hi,
I try to get interactive plotting working using spyder 2.1.8 and
ipython 0.12 on ubuntu 11.10. Interactive plotting works if I use the
normal python interpreter as well as in ipython outside of spyder.
When I load matplotlib and plot something in ipython I have to call
show() which locks the console until I close the window. If I enable
interactive plotting manually plotting doesn't work anymore (window
stays empty). Vanilla spyder configuration (deleted my .spyder2
folder).
Further, when I try to start an ipython kernel or try to connect to an
externally started kernel I get:
"ValueError: API 'QString' has already been set to version 1"
PySide 1.1.0 and PyQt4 4.7.4 are installed. I tried every possible
combination of API version and library selection in the preferences.
Didn't change anything.
Any ideas how I could get a working spyder+ipython configuration
running? Preferably the ipython kernel with pylab inline but since
there is an open bug regarding the QString problem I'd be happy if I
could get the normal ipython interpreter would work properly.
Cheers
Philipp
--
You received this message because you are subscribed to the Google Groups
"spyder" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/spyderlib?hl=en.