Example#


Revised

22 Apr 2023


Programming Environment#

Hide code cell source
from fractions import Fraction

import numpy as np
import sympy as sp
from   sympy import init_printing,latex,solve,symbols
from   sympy.matrices import diag,eye,GramSchmidt,ones,Matrix,zeros
from   sympy.solvers.inequalities import reduce_inequalities

x1,x2,x3,x4=symbols('x1 x2 x3 x4')
init_printing(use_latex=True)

import matplotlib        as mpl
import matplotlib.pyplot as plt
plt.style.use('ggplot');
plt.rcParams.update({'text.usetex' : True});
%matplotlib inline

from IPython.display import display, Math

from   datetime import datetime as d
import locale                   as l
import platform                 as p
import sys                      as s

pad = 20
print(f"{'Executed'.upper():<{pad}}: {d.now()}")
print()
print(f"{'Platform'   :<{pad}}: "
      f"{p.mac_ver()[0]} | "
      f"{p.system()} | "
      f"{p.release()} | "
      f"{p.machine()}")
print(f"{''           :<{pad}}: {l.getpreferredencoding()}")
print()
print(f"{'Python'     :<{pad}}: {s.version}")
print(f"{''           :<{pad}}: {s.version_info}")
print(f"{''           :<{pad}}: {p.python_implementation()}")
print()
print(f"{'Matplotlib' :<{pad}}: {mpl.__version__}")
print(f"{'NumPy'      :<{pad}}: {np .__version__}")
print(f"{'SymPy'      :<{pad}}: {sp .__version__}")

def unitVector (vec : np.ndarray) -> np.ndarray:
  return vec/np.sqrt((vec[0]**2+vec[1]**2))
EXECUTED            : 2024-05-21 15:46:36.326601

Platform            : 14.4.1 | Darwin | 23.4.0 | arm64
                    : UTF-8

Python              : 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]
                    : sys.version_info(major=3, minor=11, micro=9, releaselevel='final', serial=0)
                    : CPython

Matplotlib          : 3.8.4
NumPy               : 1.26.4
SymPy               : 1.12

LP#

\( \begin{aligned} \max z(\mathbf{x})&=-2x_1-x_2+2 \\ g_1(\mathbf{x})&=3x_1-7x_2\ge12=b_1 \\ g_2(\mathbf{x})&=-2x_1+5x_2\ge-20=b_2 \\ g_3(\mathbf{x})&=x_1+3x_2\le-3=b_3 \\ g_4(\mathbf{x})&=-4x_1-x_2\le8=b_4 \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \begin{aligned} \max z(\mathbf{x})&=-2x_1-x_2+2 \\ g_1(\mathbf{x})&=-3x_1+7x_2\le-12=b_1 \\ g_2(\mathbf{x})&=2x_1-5x_2\le20=b_2 \\ g_3(\mathbf{x})&=x_1+3x_2\le-3=b_3 \\ g_4(\mathbf{x})&=-4x_1-x_2\le8=b_4 \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \)


Gradients and directions#

\( \begin{aligned} \nabla z&=\langle-2,-1\rangle \\ \nabla g_1&=\langle-3,7\rangle &&\langle-2,-1\rangle\cdot\langle7,3\rangle &&\lt0 &&\implies\langle-7,-3\rangle \\ \nabla g_2&=\langle2,-5\rangle &&\langle-2,-1\rangle\cdot\langle-5,-2\rangle &&\gt0 &&\implies\langle-5,-2\rangle \\ \nabla g_3&=\langle1,3\rangle &&\langle-2,-1\rangle\cdot\langle3,-1\rangle &&\lt0 &&\implies\langle-3,1\rangle \\ \nabla g_4&=\langle-4,-1\rangle &&\langle-2,-1\rangle\cdot\langle-1,4\rangle &&\lt0 &&\implies\langle1,-4\rangle \end{aligned} \)


Non Negativity#

\( \begin{aligned} \max z(\mathbf{x})&=-2x_1-x_2+2 \\ g_1(\mathbf{x})&=-3x_1+7x_2\le-12=b_1 \\ g_2(\mathbf{x})&=2x_1-5x_2\le20=b_2 \\ g_3(\mathbf{x})&=x_1+3x_2\le-3=b_3 \\ g_4(\mathbf{x})&=-4x_1-x_2\le8=b_4 \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \begin{aligned} \max z(\mathbf{x})&=-2u_1+2u_2-u_3+u_4+2 \\ g_1(\mathbf{x})&=-3u_1+3u_2+7u_3-7u_4\le-12=b_1 \\ g_2(\mathbf{x})&=2u_1-2u_2-5u_3+5u_4\le20=b_2 \\ g_3(\mathbf{x})&=u_1-u_2+3u_3-3u_4\le-3=b_3 \\ g_4(\mathbf{x})&=-4u_1+4u_2-u_3+u_4\le8=b_4 \\ \mathbf{x}&\ge\mathbf{0} \\ x_1&=u_1-u_2 \\ x_2&=u_3-u_4 \end{aligned} \)


Matrix Form#

\( \text{LP}= \begin{aligned} \max z(\mathbf{x})&=\mathbf{cx}+d \\ \mathbf{Ax}&\le\mathbf{b} \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \)

\( \begin{aligned} z=\mathbf{cx}+d &\iff z= \begin{bmatrix} -2 & 2 & -1 & 1 \\ \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ \end{bmatrix} +2 \\ \mathbf{Ax}\le\mathbf{b} &\iff \begin{bmatrix} -3 & 3 & 7 & -7 \\ 2 & -2 & -5 & 5 \\ 1 & -1 & 3 & -3 \\ -4 & 4 & -1 & 1 \\ \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ \end{bmatrix} \le \begin{bmatrix} -12 \\ 20 \\ -3 \\ 8 \\ \end{bmatrix} \end{aligned} \)


Dual LP#

\( \boxed{ \text{LP}= \begin{aligned} \max z(\mathbf{x})&=\mathbf{cx}+d \\ \mathbf{Ax}&\le\mathbf{b} \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \overset{\text{dual to}}{\iff} \begin{aligned} \min w(\mathbf{y})&=\mathbf{yb}+d \\ \mathbf{yA}&\ge\mathbf{c} \\ \mathbf{y}&\ge\mathbf{0} \end{aligned} =\text{LP}^* } \)

\( \text{LP}= \begin{aligned} \max z(\mathbf{x})&=-2u_1+2u_2-u_3+u_4+2 \\ g_1(\mathbf{x})&=-3u_1+3u_2+7u_3-7u_4\le-12=b_1 \\ g_2(\mathbf{x})&=2u_1-2u_2-5u_3+5u_4\le20=b_2 \\ g_3(\mathbf{x})&=u_1-u_2+3u_3-3u_4\le-3=b_3 \\ g_4(\mathbf{x})&=-4u_1+4u_2-u_3+u_4\le8=b_4 \\ \mathbf{x}&\ge\mathbf{0} \\ x_1&=u_1-u_2 \\ x_2&=u_3-u_4 \end{aligned} \overset{\text{dual to}}{\iff} \begin{aligned} \min w(\mathbf{y})&=-12y_1+20y_2-3y_3+8y_4+2 \\ h_1(\mathbf{y})&=-3y_1+2y_2+y_3-4y_4\ge-2=c_1 \\ h_2(\mathbf{y})&=3y_1-2y_2-y_3+4y_4\ge2=c_2 \\ h_3(\mathbf{y})&=7y_1-5y_2+3y_3-y_4\ge-1=c_3 \\ h_4(\mathbf{y})&=-7y_1+5y_2-3y_3+y_4\ge1=c_4 \\ \mathbf{y}&\ge\mathbf{0} \end{aligned} =\text{LP}^* \)

\( \begin{aligned} w=\mathbf{yb}+d &\iff w= \begin{bmatrix} y_1 & y_2 & y_3 & y_4 \\ \end{bmatrix} \begin{bmatrix} -12 \\ 20 \\ -3 \\ 8 \\ \end{bmatrix} +2 \\ \mathbf{yA}\ge\mathbf{c} &\iff \begin{bmatrix} y_1 & y_2 & y_3 & y_4 \\ \end{bmatrix} \begin{bmatrix} -3 & 3 & 7 & -7 \\ 2 & -2 & -5 & 5 \\ 1 & -1 & 3 & -3 \\ -4 & 4 & -1 & 1 \\ \end{bmatrix} \ge \begin{bmatrix} -2 & 2 & -1 & 1 \\ \end{bmatrix} \end{aligned} \)


Optimal Solution#

\( \boxed{ \begin{aligned} z^* =\min\mathbf{cx}+d =\mathbf{(yA)x}+d =\mathbf{y(Ax)}+d =\max\mathbf{yb}+d =w^* \end{aligned} } \)

\( \begin{aligned} z^*= \begin{bmatrix} -2 & 2 & -1 & 1 \\ \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ \end{bmatrix} +2 =\begin{bmatrix} y_1 & y_2 & y_3 & y_4 \\ \end{bmatrix} \begin{bmatrix} -3 & 3 & 7 & -7 \\ 2 & -2 & -5 & 5 \\ 1 & -1 & 3 & -3 \\ -4 & 4 & -1 & 1 \\ \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ \end{bmatrix} +2 =\begin{bmatrix} y_1 & y_2 & y_3 & y_4 \\ \end{bmatrix} \begin{bmatrix} -12 \\ 20 \\ -3 \\ 8 \\ \end{bmatrix} +2 =w^* \end{aligned} \)

\( \begin{aligned} z^* &=\begin{bmatrix} -2 & 2 & -1 & 1 \\ \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ \end{bmatrix} +2 \\ &=-2u_1+2u_2-u_3+u_4+2 \\ &=\begin{bmatrix} -3y_1+2y_2+ y_3-4y_4 & 3y_1-2y_2- y_3+4y_4 & 7y_1-5y_2+3y_3- y_4 & -7y_1+5y_2-3y_3+ y_4 \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ \end{bmatrix} +2 \\ &= [-3y_1u_1+2y_2u_1+ y_3u_1-4y_4u_1] + [ 3y_1u_2-2y_2u_2- y_3u_2+4y_4u_2] + [ 7y_1u_3-5y_2u_3+3y_3u_3- y_4u_3] + [-7y_1u_4+5y_2u_4-3y_3u_4+ y_4u_4] + 2 \\ &= [-3y_1u_1+3y_1u_2+7y_1u_3-7y_1u_4] + [ 2y_2u_1-2y_2u_2-5y_2u_3+5y_2u_4] + [ y_3u_1- y_3u_2+3y_3u_3-3y_3u_4] + [-4y_4u_1+4y_4u_2- y_4u_3+ y_4u_4] + 2 \\ &=\begin{bmatrix} y_1 & y_2 & y_3 & y_4 \\ \end{bmatrix} \begin{bmatrix} -3u_1+3u_2+7u_3-7u_4 \\ 2u_1-2u_2-5u_3+5u_4 \\ u_1- u_2+3u_3-3u_4 \\ -4u_1+4u_2- u_3+ u_4 \\ \end{bmatrix} +2 \\ &=\begin{bmatrix} y_1 & y_2 & y_3 & y_4 \\ \end{bmatrix} \begin{bmatrix} -12 \\ 20 \\ -3 \\ 8 \\ \end{bmatrix} +2 \\ &=-12y_1+20y_2-3y_3+8y_4+2 \\ &=w^* \end{aligned} \)


Graphical#

d =  2
b1=-12
b2= 20
b3= -3
b4=  8

z =-2*x1-1*x2+d
g1=-3*x1+7*x2-b1
g2= 2*x1-5*x2-b2
g3= 1*x1+3*x2-b3
g4=-4*x1-1*x2-b4

# GRADIENTS & DIRECTIONS
delz =np.array([-2,-1])
delg1=np.array([-3, 7]); dg1=np.array([-7,-3])
delg2=np.array([ 2,-5]); dg2=np.array([-5,-2])
delg3=np.array([ 1, 3]); dg3=np.array([-3, 1])
delg4=np.array([-4,-1]); dg4=np.array([ 1,-4])

# UNIT DIRECTION VECTORS
udg1=dg1/np.sqrt(dg1[0]**2+dg1[1]**2)
udg2=dg2/np.sqrt(dg2[0]**2+dg2[1]**2)
udg3=dg3/np.sqrt(dg3[0]**2+dg3[1]**2)
udg4=dg4/np.sqrt(dg4[0]**2+dg4[1]**2)

print(f"{delz.dot(dg1):>3}")
print(f"{delz.dot(dg2):>3}")
print(f"{delz.dot(dg3):>3}")
print(f"{delz.dot(dg4):>3}")

# LINES & INTERSECTIONS
display(
'LINES',
'g1',solve(g1,x2,dict=True)[0],
'g2',solve(g2,x2,dict=True)[0],
'g3',solve(g3,x2,dict=True)[0],
'g4',solve(g4,x2,dict=True)[0],
)

display(
reduce_inequalities(g1<=0,[x2]),
reduce_inequalities(g2<=0,[x2]),
reduce_inequalities(g3<=0,[x2]),
reduce_inequalities(g4<=0,[x2]),
)

display(
'INTERSECTIONS',
'g1=g2',   solve([g1,g2],  [x1,x2],dict=True)[0],
'g1=g3',   solve([g1,g3],  [x1,x2],dict=True)[0],
'g1=g4',   solve([g1,g4],  [x1,x2],dict=True)[0],
'g2=g3',   solve([g2,g3],  [x1,x2],dict=True)[0],
'g2=g4',   solve([g2,g4],  [x1,x2],dict=True)[0],
'g3=g4',   solve([g3,g4],  [x1,x2],dict=True)[0],
'g1[6,x2]',solve([g1,x1-6],[x1,x2],dict=True)[0],
'g1[0,x2]',solve([g1,x1  ],[x1,x2],dict=True)[0],
'g2[6,x2]',solve([g2,x1-6],[x1,x2],dict=True)[0],
'g3[6,x2]',solve([g3,x1-6],[x1,x2],dict=True)[0],
'g4[0, 6]',solve([g4,x2-6],[x1,x2],dict=True)[0],
)
 17
 12
  5
  2
'LINES'
'g1'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{2} : \frac{3 x_{1}}{7} - \frac{12}{7}\right\}\]
'g2'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{2} : \frac{2 x_{1}}{5} - 4\right\}\]
'g3'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{2} : - \frac{x_{1}}{3} - 1\right\}\]
'g4'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{2} : - 4 x_{1} - 8\right\}\]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
    345     method = get_real_method(obj, self.print_method)
    346     if method is not None:
--> 347         return method()
    348     return None
    349 else:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle x_{2} \leq \frac{3 x_{1}}{7} - \frac{12}{7} \wedge -\infty < x_{2}\]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
    345     method = get_real_method(obj, self.print_method)
    346     if method is not None:
--> 347         return method()
    348     return None
    349 else:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle x_{2} \geq \frac{2 x_{1}}{5} - 4 \wedge x_{2} < \infty\]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
    345     method = get_real_method(obj, self.print_method)
    346     if method is not None:
--> 347         return method()
    348     return None
    349 else:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle x_{2} \leq - \frac{x_{1}}{3} - 1 \wedge -\infty < x_{2}\]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
    345     method = get_real_method(obj, self.print_method)
    346     if method is not None:
--> 347         return method()
    348     return None
    349 else:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle x_{2} \geq - 4 x_{1} - 8 \wedge x_{2} < \infty\]
'INTERSECTIONS'
'g1=g2'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : -80, \ x_{2} : -36\right\}\]
'g1=g3'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : \frac{15}{16}, \ x_{2} : - \frac{21}{16}\right\}\]
'g1=g4'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : - \frac{44}{31}, \ x_{2} : - \frac{72}{31}\right\}\]
'g2=g3'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : \frac{45}{11}, \ x_{2} : - \frac{26}{11}\right\}\]
'g2=g4'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : - \frac{10}{11}, \ x_{2} : - \frac{48}{11}\right\}\]
'g3=g4'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : - \frac{21}{11}, \ x_{2} : - \frac{4}{11}\right\}\]
'g1[6,x2]'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : 6, \ x_{2} : \frac{6}{7}\right\}\]
'g1[0,x2]'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : 0, \ x_{2} : - \frac{12}{7}\right\}\]
'g2[6,x2]'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : 6, \ x_{2} : - \frac{8}{5}\right\}\]
'g3[6,x2]'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : 6, \ x_{2} : -3\right\}\]
'g4[0, 6]'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   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,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   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.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    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",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle \left\{ x_{1} : - \frac{7}{2}, \ x_{2} : 6\right\}\]
# zStar

print(z.subs([
  (x1,-(10/11)),
  (x2,-(48/11)),
]))

print(Fraction(float(z.subs([
  (x1,-(10/11)),
  (x2,-(48/11)),
]))).limit_denominator(100))
8.18181818181818
90/11
Hide code cell source
s =6
x =np.linspace(-s,s,1001)

# LINES
y1= (3/7)*x-(12/7)
y2= (2/5)*x-( 4/1)
y3=-(1/3)*x-( 1/1)
y4=-(4/1)*x-( 8/1)

fig=plt.figure(dpi=200);
ax =plt.subplot();
ax.set_aspect(1);

# LINES
ax.plot(x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax.plot(x,y2,label='g2=b2',linewidth=0.5,color='yellow');
ax.plot(x,y3,label='g3=b3',linewidth=0.5,color='green');
ax.plot(x,y4,label='g4=b4',linewidth=0.5,color='red');

# delz
ax.arrow(0,0,*unitVector(delz),width=0.1,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax.arrow(0,0,*unitVector(-delg1),color='blue',  width=0.01,head_width=0.1,length_includes_head=True);
ax.arrow(0,0,*unitVector(-delg2),color='yellow',width=0.01,head_width=0.1,length_includes_head=True);
ax.arrow(0,0,*unitVector(-delg3),color='green', width=0.01,head_width=0.1,length_includes_head=True);
ax.arrow(0,0,*unitVector(-delg4),color='red',   width=0.01,head_width=0.1,length_includes_head=True);

# DIRECTIONS
ax.arrow( (6/1), (6/7),udg1[0],udg1[1],width=0.1,length_includes_head=True,color='blue');
ax.arrow( (6/1),-(8/5),udg2[0],udg2[1],width=0.1,length_includes_head=True,color='yellow');
ax.arrow( (6/1),-(3/1),udg3[0],udg3[1],width=0.1,length_includes_head=True,color='green');
ax.arrow(-(7/2), (6/1),udg4[0],udg4[1],width=0.1,length_includes_head=True,color='red');

fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
      ( fy<= (3/7)*fx-(12/7))
    & (-fy<=-(2/5)*fx+( 4/1))
    & ( fy<=-(1/3)*fx-( 1/1))
    & (-fy<= (4/1)*fx+( 8/1))
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax.set_xlim(-s,s);
ax.set_ylim(-s,s);
ax.legend();

# xStar
ax.scatter(-(10/11),-(48/11),s=1e2,color='purple');

xStar=(
  r'\begin{eqnarray*}'
  r'x^*&=&\left(-\frac{10}{11},-\frac{48}{11}\right)'
  r'\\'
  r'z^*&=&\frac{90}{11}'
  r'\end{eqnarray*}'
)
ax.text(-2,4,xStar,fontsize=10);

# SIMPLEX
dx,dy=0.2,0.2
ax.annotate('$A$',(0+dx,0+dy));
ax.annotate('$B$',(4+dx,0+dy));
ax.annotate('$C$',( (15/16)+dx,-(21/16)+dy));
ax.annotate('$D$',( (    0)+dx,-(12/ 7)+dy));
ax.annotate('$E$',( (    0)+dx,-(    4)+dy));
ax.annotate('$F$',(-(10/11)+dx,-(48/11)+dy));
Error in callback <function _draw_all_if_interactive at 0x1285e8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
   1891 if not self._is_idle_drawing:
   1892     with self._idle_draw_cntx():
-> 1893         self.draw(*args, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    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.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2161     # we do this instead of `self.figure.draw_without_rendering`
   2162     # so that we can inject the orientation
   2163     with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164         self.figure.draw(renderer)
   2165 if bbox_inches:
   2166     if bbox_inches == "tight":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.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()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, 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
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__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, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._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, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 1280x960 with 1 Axes>

Simplex Algorithm#

def pivot (iStar,jStar,tab):
  nRows =tab.shape[0]-1
  nCols =tab.shape[1]-1
  newTab=tab[:,:]

  newTab[0,jStar]    =tab[iStar,nCols]
  newTab[iStar,nCols]=tab[0,jStar]
  newTab[iStar,0]    =-tab[nRows,jStar]
  newTab[nRows,jStar]=-tab[iStar,0]
  
  for i in range(1,nRows):
    for j in range(1,nCols):
      if   i==iStar and j==jStar:
        newTab[i,j]=1/tab[iStar,jStar]
      elif i==iStar and j!=jStar:
        newTab[i,j]=-tab[i,j]/tab[iStar,jStar]
      elif i!=iStar and j==jStar:
        newTab[i,j]= tab[i,j]/tab[iStar,jStar]
      elif i!=iStar and j!=jStar:
        newTab[i,j]= tab[i,j]-tab[iStar,j]*tab[i,jStar]/tab[iStar,jStar]
  return newTab
A = Matrix([
  [ 'c', 'u1', 'u2', 'u3','u4',  1, 'r'],
  ['y1',    3,   -3,   -7,   7,-12,'s1'],
  ['y2',   -2,    2,    5,  -5, 20,'s2'],
  ['y3',   -1,    1,   -3,   3, -3,'s3'],
  ['y4',    4,   -4,    1,  -1,  8,'s4'],
  [  -1,    2,   -2,    1,  -1, -2,'-z'],
  [ 'c','-v1', '-v2','-v3','-v4','w', 'r'],
])
B = pivot(1,1,A)
C = pivot(3,4,B)
D = pivot(1,4,C)
E = pivot(2,1,D)
F = pivot(4,2,E)

display(
  Math(fr'A = {latex(A)}\,\,\,\,\,x_1=x_2=0'),
  Math(fr'B = {latex(B)}\,\,\,\,\,x_2=s_1=0'),
  Math(fr'C = {latex(C)}\,\,\,\,\,s_1=s_3=0'),
  Math(fr'D = {latex(D)}\,\,\,\,\,x_1=s_1=0'),
  Math(fr'E = {latex(E)}\,\,\,\,\,x_1=s_2=0'),
  Math(fr'F = {latex(F)}\,\,\,\,\,s_2=s_4=0'),
)
\[\begin{split}\displaystyle A = \left[\begin{matrix}c & u_{1} & u_{2} & u_{3} & u_{4} & 1 & r\\y_{1} & 3 & -3 & -7 & 7 & -12 & s_{1}\\y_{2} & -2 & 2 & 5 & -5 & 20 & s_{2}\\y_{3} & -1 & 1 & -3 & 3 & -3 & s_{3}\\y_{4} & 4 & -4 & 1 & -1 & 8 & s_{4}\\-1 & 2 & -2 & 1 & -1 & -2 & - z\\c & - v_{1} & - v_{2} & - v_{3} & - v_{4} & w & r\end{matrix}\right]\,\,\,\,\,x_1=x_2=0\end{split}\]
\[\begin{split}\displaystyle B = \left[\begin{matrix}c & s_{1} & u_{2} & u_{3} & u_{4} & 1 & r\\v_{1} & \frac{1}{3} & 1 & \frac{7}{3} & - \frac{7}{3} & 4 & u_{1}\\y_{2} & - \frac{2}{3} & 0 & \frac{1}{3} & - \frac{1}{3} & 12 & s_{2}\\y_{3} & - \frac{1}{3} & 0 & - \frac{16}{3} & \frac{16}{3} & -7 & s_{3}\\y_{4} & \frac{4}{3} & 0 & \frac{31}{3} & - \frac{31}{3} & 24 & s_{4}\\-1 & \frac{2}{3} & 0 & \frac{17}{3} & - \frac{17}{3} & 6 & - z\\c & - y_{1} & - v_{2} & - v_{3} & - v_{4} & w & r\end{matrix}\right]\,\,\,\,\,x_2=s_1=0\end{split}\]
\[\begin{split}\displaystyle C = \left[\begin{matrix}c & s_{1} & u_{2} & u_{3} & s_{3} & 1 & r\\v_{1} & \frac{3}{16} & 1 & 0 & - \frac{7}{16} & \frac{15}{16} & u_{1}\\y_{2} & - \frac{11}{16} & 0 & 0 & - \frac{1}{16} & \frac{185}{16} & s_{2}\\v_{4} & \frac{1}{16} & 0 & 1 & \frac{3}{16} & \frac{21}{16} & u_{4}\\y_{4} & \frac{11}{16} & 0 & 0 & - \frac{31}{16} & \frac{167}{16} & s_{4}\\-1 & \frac{5}{16} & 0 & 0 & - \frac{17}{16} & - \frac{23}{16} & - z\\c & - y_{1} & - v_{2} & - v_{3} & - y_{3} & w & r\end{matrix}\right]\,\,\,\,\,s_1=s_3=0\end{split}\]
\[\begin{split}\displaystyle D = \left[\begin{matrix}c & s_{1} & u_{2} & u_{3} & u_{1} & 1 & r\\y_{3} & \frac{3}{7} & \frac{16}{7} & 0 & - \frac{16}{7} & \frac{15}{7} & s_{3}\\y_{2} & - \frac{5}{7} & - \frac{1}{7} & 0 & \frac{1}{7} & \frac{80}{7} & s_{2}\\v_{4} & \frac{1}{7} & \frac{3}{7} & 1 & - \frac{3}{7} & \frac{12}{7} & u_{4}\\y_{4} & - \frac{1}{7} & - \frac{31}{7} & 0 & \frac{31}{7} & \frac{44}{7} & s_{4}\\-1 & - \frac{1}{7} & - \frac{17}{7} & 0 & \frac{17}{7} & - \frac{26}{7} & - z\\c & - y_{1} & - v_{2} & - v_{3} & - v_{1} & w & r\end{matrix}\right]\,\,\,\,\,x_1=s_1=0\end{split}\]
\[\begin{split}\displaystyle E = \left[\begin{matrix}c & s_{2} & u_{2} & u_{3} & u_{1} & 1 & r\\y_{3} & - \frac{3}{5} & \frac{11}{5} & 0 & - \frac{11}{5} & 9 & s_{3}\\y_{1} & - \frac{7}{5} & - \frac{1}{5} & 0 & \frac{1}{5} & 16 & s_{1}\\v_{4} & - \frac{1}{5} & \frac{2}{5} & 1 & - \frac{2}{5} & 4 & u_{4}\\y_{4} & \frac{1}{5} & - \frac{22}{5} & 0 & \frac{22}{5} & 4 & s_{4}\\-1 & \frac{1}{5} & - \frac{12}{5} & 0 & \frac{12}{5} & -6 & - z\\c & - y_{2} & - v_{2} & - v_{3} & - v_{1} & w & r\end{matrix}\right]\,\,\,\,\,x_1=s_2=0\end{split}\]
\[\begin{split}\displaystyle F = \left[\begin{matrix}c & s_{2} & s_{4} & u_{3} & u_{1} & 1 & r\\y_{3} & - \frac{1}{2} & - \frac{1}{2} & 0 & 0 & 11 & s_{3}\\y_{1} & - \frac{31}{22} & \frac{1}{22} & 0 & 0 & \frac{174}{11} & s_{1}\\v_{4} & - \frac{2}{11} & - \frac{1}{11} & 1 & 0 & \frac{48}{11} & u_{4}\\v_{2} & \frac{1}{22} & - \frac{5}{22} & 0 & 1 & \frac{10}{11} & u_{2}\\-1 & \frac{1}{11} & \frac{6}{11} & 0 & 0 & - \frac{90}{11} & - z\\c & - y_{2} & - y_{4} & - v_{3} & - v_{1} & w & r\end{matrix}\right]\,\,\,\,\,s_2=s_4=0\end{split}\]