guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

python-matplotlib: should it propagate numpy?


From: Federico Beffa
Subject: python-matplotlib: should it propagate numpy?
Date: Wed, 11 Nov 2015 20:09:56 +0100

Ricardo Wurmus <address@hidden> writes:

> Hi Guix,
>
> with a profile containing python-2.7.10 and python2-matplotlib I did
> this:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~
> address@hidden:~] $ export
> GI_TYPELIB_PATH="$HOME/.guix-profile/lib/girepository-1.0"
> address@hidden:~] $ export
> PYTHONPATH=$HOME/.guix-profile/lib/python2.7/site-packages
> address@hidden:~] $ python
> Python 2.7.10 (default, Oct  9 2015, 22:48:33)
> [GCC 4.9.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import matplotlib.pyplot as plt
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/__init__.py",
>  line 180, in <module>
>     from matplotlib.cbook import is_string_like
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/cbook.py",
>  line 33, in <module>
>     import numpy as np
> ImportError: No module named numpy
>>>>
> ~~~~~~~~~~~~~~~~~~~~~~~~

Yeah, we should propagate numpy really.

>
>
> So I installed python2-numpy into the same profile and tried again.
> This time the import statement did pass, but I cannot actually plot
> anything.
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~
>>>> import matplotlib.pyplot as plt
>>>> import numpy as np
>>>> t = np.r_[0:5]
>>>> plt.plot(t, t)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py",
>  line 3092, in plot
>     ax = gca()
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py",
>  line 828, in gca
>     ax =  gcf().gca(**kwargs)
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py",
>  line 462, in gcf
>     return figure()
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/pyplot.py",
>  line 435, in figure
>     **kwargs)
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py",
>  line 110, in new_figure_manager
>     return new_figure_manager_given_figure(num, thisFig)
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py",
>  line 117, in new_figure_manager_given_figure
>     canvas = FigureCanvasGTK3Agg(figure)
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py",
>  line 25, in __init__
>     backend_gtk3.FigureCanvasGTK3.__init__(self, figure)
>   File 
> "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3.py",
>  line 210, in __init__
>     self._idle_event_id = GLib.idle_add(self.idle_event)
>   File "/home/rwurmus/.guix-profile/lib/python2.7/site-packages/gi/types.py", 
> line 44, in function
>     return info.invoke(*args)
> TypeError: Error invoking GLib.idle_add: Unexpected value for argument 
> 'function'
>>>>
> ~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> Does anyone know how to make this work?  Is this related to bug #20888?

Yes, it looks like it is related to bug #20888. You may wont to try the
'magic' command '%matplotlib' before importing it.

Matplotlib supports several back-ends, some of them like 'Agg' can only
be used to generate files, while others like 'GTK3Agg' do support
interactive operation. Of all the interactive ones, 'GTK3Agg' was the
only one where we had all the pieces to make it work. Unfortunately an
upgrade of GTK+ did break interoperability with matplotlib.

I tried several times to fix the 'GTK3Agg' back-end without success. So,
after a while I started asking to include the library 'tkinter' in our
python (see bug #20889). This would allows us to use another interactive
back-end. We are almost there, but not quite yet.

In the mean time I discovered and packaged 'emacs-ob-ipython' which
allows one to use ipython, including plotting with maptlotlib, inside of
an org-mode buffer.

Regards,
Fede



reply via email to

[Prev in Thread] Current Thread [Next in Thread]