|
From: Benjamin R. <ben...@ou...> - 2012-09-03 13:30:31
|
On Monday, September 3, 2012, Chao YUE wrote:
> Dear all,
>
> I have a module written by myself which use
> python-netcdf/matplotlib/numpy/basemap for treating and mapping of netcdf
> files.
> so in the module I have a line:
>
> import matplotlib.pyplot as plt
>
> But now I am using some function of this module which do not involve the
> visualisation. And I want to use it in a batch mode submitted by qsub
> command.
> And then I have traceback like following:
>
> File "/home/orchidee01/ychao/SCRIPT/combine.py", line 1, in <module>
> import gnc
> File "/home/users/ychao/python/python_lib/gnc.py", line 4, in <module>
> import matplotlib.pyplot as plt
> File
> "/usr/local/install/matplotlib-1.1.0/lib64/python2.6/site-packages/matplotlib/pyplot.py",
> line 95, in <module>
> new_figure_manager, draw_if_interactive, _show = pylab_setup()
> File
> "/usr/local/install/matplotlib-1.1.0/lib64/python2.6/site-packages/matplotlib/backends/__init__.py",
> line 25, in pylab_setup
> globals(),locals(),[backend_name])
> File
> "/usr/local/install/matplotlib-1.1.0/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py",
> line 10, in <module>
> from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK,
> FigureCanvasGTK,\
> File
> "/usr/local/install/matplotlib-1.1.0/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py",
> line 8, in <module>
> import gtk; gdk = gtk.gdk
> File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line
> 64, in <module>
> _init()
> File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line
> 52, in _init
> _gtk.init_check()
> RuntimeError: could not open display
>
> From the last line, I think this is because I cannot use this module in a
> non-interactive mode. So is there a way I can bypass this issue and still
> use the module in a non-interactive mode? Thanks a lot for any
> information.
>
> Chao
>
>
import matplotlib
matplotlib.use("AGG")
Or set that in the matplotlibrc file.
Cheers,
Ben Root
|