开发者

Problem importing pylab in Ubuntu 8.1

I have installed numpy1.3,scipy 0.7.1,matplotlib 0.99.1.1 and python 2.5 when I import pylab I get the following error. Someone please help.

 /var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py:72: GtkWarning: could n开发者_如何学JAVAot open display
      warnings.warn(str(e), _gtk.Warning)
    /usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:44: GtkWarning: gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed
      cursors.MOVE          : gdk.Cursor(gdk.FLEUR),
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.5/site-packages/pylab.py", line 1, in <module>
        from matplotlib.pylab import *
      File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line 247, in <module>
        from matplotlib.pyplot import *
      File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 78, in <module>
        new_figure_manager, draw_if_interactive, show = pylab_setup()
      File "/usr/lib/python2.5/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
        globals(),locals(),[backend_name])
      File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
        from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
      File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 44, in <module>
        cursors.MOVE          : gdk.Cursor(gdk.FLEUR),
    RuntimeError: could not create GdkCursor object


try using a different backend for plotting than Gtk.

Open the python console and type:

>>> import matplotlib
>>> matplotlib.matplotlib_fname()

This will print a file name. Edit this file and modify the section 'Backend' and change Gtk or GtkAgg with any other (see the documentation in the same file), until you get it working. You can find more information about backends here.

As for why you get an error when you try to use that backend, it depends on how you have installed the libraries and what you have installed on your computer. I would recommend to install matplotlib with synaptic/yum and selecting all optional dependencies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜