Unable to plot anything with Alma9 jupyter

Here is the final error I receive:

RuntimeError: Failed to process string with tex because dvipng could not be found

This appears on the same cells that work with the old centos7 image. Here is the full error log:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(cls, command, tex, cwd)
    249         try:
--> 250             report = subprocess.check_output(
    251                 command, cwd=cwd if cwd is not None else cls._texcache,

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in check_output(timeout, *popenargs, **kwargs)
    423 
--> 424     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    425                **kwargs).stdout

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    504 
--> 505     with Popen(*popenargs, **kwargs) as process:
    506         try:

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask)
    950 
--> 951             self._execute_child(args, executable, preexec_fn, close_fds,
    952                                 pass_fds, cwd, env,

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
   1820                         err_msg = os.strerror(errno_num)
-> 1821                     raise child_exception_type(errno_num, err_msg, err_filename)
   1822                 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'dvipng'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/pyplot.py in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()
    198 
    199 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/_pylab_helpers.py in draw_all(cls, force)
    130         for manager in cls.get_all_fig_managers():
    131             if force or manager.canvas.figure.stale:
--> 132                 manager.canvas.draw_idle()
    133 
    134 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backend_bases.py in draw_idle(self, *args, **kwargs)
   1891         if not self._is_idle_drawing:
   1892             with self._idle_draw_cntx():
-> 1893                 self.draw(*args, **kwargs)
   1894 
   1895     @property

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in draw(self)
    386         with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387               else nullcontext()):
--> 388             self.figure.draw(self.renderer)
    389             # A GUI class may be need to update a window using this draw, so
    390             # don't forget to call the superclass.

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     93     @wraps(draw)
     94     def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95         result = draw(artist, renderer, *args, **kwargs)
     96         if renderer._rasterizing:
     97             renderer.stop_rasterizing()

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/figure.py in draw(self, renderer)
   3152 
   3153                 self.patch.draw(renderer)
-> 3154                 mimage._draw_list_compositing_images(
   3155                     renderer, self, artists, self.suppressComposite)
   3156 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130     if not_composite or not has_images:
    131         for a in artists:
--> 132             a.draw(renderer)
    133     else:
    134         # Composite any adjacent images together

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/axes/_base.py in draw(self, renderer)
   3068             _draw_rasterized(self.figure, artists_rasterized, renderer)
   3069 
-> 3070         mimage._draw_list_compositing_images(
   3071             renderer, self, artists, self.figure.suppressComposite)
   3072 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130     if not_composite or not has_images:
    131         for a in artists:
--> 132             a.draw(renderer)
    133     else:
    134         # Composite any adjacent images together

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)
   1389 
   1390         for tick in ticks_to_draw:
-> 1391             tick.draw(renderer)
   1392 
   1393         # Shift label away from axes to avoid overlapping ticklabels.

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/axis.py in draw(self, renderer)
    293         for artist in [self.gridline, self.tick1line, self.tick2line,
    294                        self.label1, self.label2]:
--> 295             artist.draw(renderer)
    296         renderer.close_group(self.__name__)
    297         self.stale = False

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/text.py in draw(self, renderer)
    791 
    792                 if self.get_usetex():
--> 793                     textrenderer.draw_tex(gc, x, y, clean_line,
    794                                           self._fontproperties, angle,
    795                                           mtext=mtext)

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in draw_tex(self, gc, x, y, s, prop, angle, mtext)
    234         texmanager = self.get_texmanager()
    235 
--> 236         Z = texmanager.get_grey(s, size, self.dpi)
    237         Z = np.array(Z * 255.0, np.uint8)
    238 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in get_grey(cls, tex, fontsize, dpi)
    334         alpha = cls._grey_arrayd.get(key)
    335         if alpha is None:
--> 336             pngfile = cls.make_png(tex, fontsize, dpi)
    337             rgba = mpl.image.imread(os.path.join(cls._texcache, pngfile))
    338             cls._grey_arrayd[key] = alpha = rgba[:, :, -1]

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in make_png(cls, tex, fontsize, dpi)
    321                     mpl._get_executable_info("dvipng").raw_version != "1.16"):
    322                 cmd.insert(1, "--freetype0")
--> 323             cls._run_checked_subprocess(cmd, tex)
    324         return pngfile
    325 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(cls, command, tex, cwd)
    252                 stderr=subprocess.STDOUT)
    253         except FileNotFoundError as exc:
--> 254             raise RuntimeError(
    255                 f'Failed to process string with tex because {command[0]} '
    256                 'could not be found') from exc

RuntimeError: Failed to process string with tex because dvipng could not be found

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(cls, command, tex, cwd)
    249         try:
--> 250             report = subprocess.check_output(
    251                 command, cwd=cwd if cwd is not None else cls._texcache,

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in check_output(timeout, *popenargs, **kwargs)
    423 
--> 424     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    425                **kwargs).stdout

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    504 
--> 505     with Popen(*popenargs, **kwargs) as process:
    506         try:

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask)
    950 
--> 951             self._execute_child(args, executable, preexec_fn, close_fds,
    952                                 pass_fds, cwd, env,

/cvmfs/sft.cern.ch/lcg/releases/Python/3.9.12-9a1bc/x86_64-el9-gcc13-opt/lib/python3.9/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
   1820                         err_msg = os.strerror(errno_num)
-> 1821                     raise child_exception_type(errno_num, err_msg, err_filename)
   1822                 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'dvipng'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/IPython/core/formatters.py in __call__(self, obj)
    339                 pass
    340             else:
--> 341                 return printer(obj)
    342             # Finally look for special method names
    343             method = get_real_method(obj, self.print_method)

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/IPython/core/pylabtools.py in <lambda>(fig)
    248 
    249     if 'png' in formats:
--> 250         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    251     if 'retina' in formats or 'png2x' in formats:
    252         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
    132         FigureCanvasBase(fig)
    133 
--> 134     fig.canvas.print_figure(bytes_io, **kw)
    135     data = bytes_io.getvalue()
    136     if fmt == 'svg':

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2191                 # force the figure dpi to 72), so we need to set it again here.
   2192                 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193                     result = print_method(
   2194                         filename,
   2195                         facecolor=facecolor,

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backend_bases.py in <lambda>(*args, **kwargs)
   2041                 "bbox_inches_restore"}
   2042             skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043             print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
   2044                 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
   2045         else:  # Let third-parties do as they see fit.

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, metadata, pil_kwargs)
    495             *metadata*, including the default 'Software' key.
    496         """
--> 497         self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
    498 
    499     def print_to_buffer(self):

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    443         *pil_kwargs* and *metadata* are forwarded).
    444         """
--> 445         FigureCanvasAgg.draw(self)
    446         mpl.image.imsave(
    447             filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in draw(self)
    386         with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387               else nullcontext()):
--> 388             self.figure.draw(self.renderer)
    389             # A GUI class may be need to update a window using this draw, so
    390             # don't forget to call the superclass.

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     93     @wraps(draw)
     94     def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95         result = draw(artist, renderer, *args, **kwargs)
     96         if renderer._rasterizing:
     97             renderer.stop_rasterizing()

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/figure.py in draw(self, renderer)
   3152 
   3153                 self.patch.draw(renderer)
-> 3154                 mimage._draw_list_compositing_images(
   3155                     renderer, self, artists, self.suppressComposite)
   3156 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130     if not_composite or not has_images:
    131         for a in artists:
--> 132             a.draw(renderer)
    133     else:
    134         # Composite any adjacent images together

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/axes/_base.py in draw(self, renderer)
   3068             _draw_rasterized(self.figure, artists_rasterized, renderer)
   3069 
-> 3070         mimage._draw_list_compositing_images(
   3071             renderer, self, artists, self.figure.suppressComposite)
   3072 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130     if not_composite or not has_images:
    131         for a in artists:
--> 132             a.draw(renderer)
    133     else:
    134         # Composite any adjacent images together

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)
   1389 
   1390         for tick in ticks_to_draw:
-> 1391             tick.draw(renderer)
   1392 
   1393         # Shift label away from axes to avoid overlapping ticklabels.

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/axis.py in draw(self, renderer)
    293         for artist in [self.gridline, self.tick1line, self.tick2line,
    294                        self.label1, self.label2]:
--> 295             artist.draw(renderer)
    296         renderer.close_group(self.__name__)
    297         self.stale = False

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)
     70                 renderer.start_filter()
     71 
---> 72             return draw(artist, renderer)
     73         finally:
     74             if artist.get_agg_filter() is not None:

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/text.py in draw(self, renderer)
    791 
    792                 if self.get_usetex():
--> 793                     textrenderer.draw_tex(gc, x, y, clean_line,
    794                                           self._fontproperties, angle,
    795                                           mtext=mtext)

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in draw_tex(self, gc, x, y, s, prop, angle, mtext)
    234         texmanager = self.get_texmanager()
    235 
--> 236         Z = texmanager.get_grey(s, size, self.dpi)
    237         Z = np.array(Z * 255.0, np.uint8)
    238 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in get_grey(cls, tex, fontsize, dpi)
    334         alpha = cls._grey_arrayd.get(key)
    335         if alpha is None:
--> 336             pngfile = cls.make_png(tex, fontsize, dpi)
    337             rgba = mpl.image.imread(os.path.join(cls._texcache, pngfile))
    338             cls._grey_arrayd[key] = alpha = rgba[:, :, -1]

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in make_png(cls, tex, fontsize, dpi)
    321                     mpl._get_executable_info("dvipng").raw_version != "1.16"):
    322                 cmd.insert(1, "--freetype0")
--> 323             cls._run_checked_subprocess(cmd, tex)
    324         return pngfile
    325 

/cvmfs/sft.cern.ch/lcg/views/LCG_105a_swan/x86_64-el9-gcc13-opt/lib/python3.9/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(cls, command, tex, cwd)
    252                 stderr=subprocess.STDOUT)
    253         except FileNotFoundError as exc:
--> 254             raise RuntimeError(
    255                 f'Failed to process string with tex because {command[0]} '
    256                 'could not be found') from exc

RuntimeError: Failed to process string with tex because dvipng could not be found

Dear Lukas,

Can you please provide the notebook you are using?

Best,
Pedro

Hi Lukas,

I guess it’s something like this that you are trying:

import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['text.usetex'] = True


t = np.linspace(0.0, 1.0, 100)
s = np.cos(4 * np.pi * t) + 2

fig, ax = plt.subplots(figsize=(6, 4), tight_layout=True)
ax.plot(t, s)

ax.set_xlabel(r'\textbf{time (s)}')
ax.set_ylabel('\\textit{Velocity (\N{DEGREE SIGN}/sec)}', fontsize=16)
ax.set_title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
             r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')

Indeed dvipng is not installed in the Alma9 image and that is why this code fails, as the error message indicates. We created this jira ticket to take care of it, it will be deployed the next time we update the alma9 image:

https://its.cern.ch/jira/browse/SWAN-178