Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to process string with tex because latex could not be found #47

Open
arre-ankit opened this issue Mar 22, 2023 · 1 comment
Open

Comments

@arre-ankit
Copy link

arre-ankit commented Mar 22, 2023

**I would like to fix this error please assign me this error **

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

In the code follows : https://github.com/maziarraissi/PINNs/blob/master/appendix/continuous_time_identification%20(Burgers)/Burgers.py#L224-L288

` ######################################################################
############################# Plotting ###############################
######################################################################

fig, ax = newfig(1.0, 1.4)
ax.axis('off')

####### Row 0: u(t,x) ##################    
gs0 = gridspec.GridSpec(1, 2)
gs0.update(top=1-0.06, bottom=1-1.0/3.0+0.06, left=0.15, right=0.85, wspace=0)
ax = plt.subplot(gs0[:, :])

h = ax.imshow(U_pred.T, interpolation='nearest', cmap='rainbow', 
              extent=[t.min(), t.max(), x.min(), x.max()], 
              origin='lower', aspect='auto')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
fig.colorbar(h, cax=cax)

ax.plot(X_u_train[:,1], X_u_train[:,0], 'kx', label = 'Data (%d points)' % (u_train.shape[0]), markersize = 2, clip_on = False)

line = np.linspace(x.min(), x.max(), 2)[:,None]
ax.plot(t[25]*np.ones((2,1)), line, 'w-', linewidth = 1)
ax.plot(t[50]*np.ones((2,1)), line, 'w-', linewidth = 1)
ax.plot(t[75]*np.ones((2,1)), line, 'w-', linewidth = 1)

ax.set_xlabel('$t$')
ax.set_ylabel('$x$')
ax.legend(loc='upper center', bbox_to_anchor=(1.0, -0.125), ncol=5, frameon=False)
ax.set_title('$u(t,x)$', fontsize = 10)

####### Row 1: u(t,x) slices ##################    
gs1 = gridspec.GridSpec(1, 3)
gs1.update(top=1-1.0/3.0-0.1, bottom=1.0-2.0/3.0, left=0.1, right=0.9, wspace=0.5)

ax = plt.subplot(gs1[0, 0])
ax.plot(x,Exact[25,:], 'b-', linewidth = 2, label = 'Exact')       
ax.plot(x,U_pred[25,:], 'r--', linewidth = 2, label = 'Prediction')
ax.set_xlabel('$x$')
ax.set_ylabel('$u(t,x)$')    
ax.set_title('$t = 0.25$', fontsize = 10)
ax.axis('square')
ax.set_xlim([-1.1,1.1])
ax.set_ylim([-1.1,1.1])

ax = plt.subplot(gs1[0, 1])
ax.plot(x,Exact[50,:], 'b-', linewidth = 2, label = 'Exact')       
ax.plot(x,U_pred[50,:], 'r--', linewidth = 2, label = 'Prediction')
ax.set_xlabel('$x$')
ax.set_ylabel('$u(t,x)$')
ax.axis('square')
ax.set_xlim([-1.1,1.1])
ax.set_ylim([-1.1,1.1])
ax.set_title('$t = 0.50$', fontsize = 10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.35), ncol=5, frameon=False)

ax = plt.subplot(gs1[0, 2])
ax.plot(x,Exact[75,:], 'b-', linewidth = 2, label = 'Exact')       
ax.plot(x,U_pred[75,:], 'r--', linewidth = 2, label = 'Prediction')
ax.set_xlabel('$x$')
ax.set_ylabel('$u(t,x)$')
ax.axis('square')
ax.set_xlim([-1.1,1.1])
ax.set_ylim([-1.1,1.1])    
ax.set_title('$t = 0.75$', fontsize = 10)
`

I am getting the error :

`Text(0.5, 1.0, '$t = 0.75$')

FileNotFoundError Traceback (most recent call last)
~\anaconda3\envs\xyz\lib\site-packages\matplotlib\texmanager.py in _run_checked_subprocess(self, command, tex)
276 cwd=self.texcache,
--> 277 stderr=subprocess.STDOUT)
278 except FileNotFoundError as exc:

~\anaconda3\envs\xyz\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
355 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 356 **kwargs).stdout
357

~\anaconda3\envs\xyz\lib\subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
422
--> 423 with Popen(*popenargs, **kwargs) as process:
424 try:

~\anaconda3\envs\xyz\lib\subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
728 errread, errwrite,
--> 729 restore_signals, start_new_session)
730 except:

~\anaconda3\envs\xyz\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1016 os.fspath(cwd) if cwd is not None else None,
-> 1017 startupinfo)
1018 finally:

FileNotFoundError: [WinError 2] The system cannot find the file specified

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

RuntimeError Traceback (most recent call last)
~\anaconda3\envs\xyz\lib\site-packages\IPython\core\formatters.py in call(self, obj)
339 pass
340 else:
--> 341 return printer(obj)
342 # Finally look for special method names
343 method = get_real_method(obj, self.print_method)

~\anaconda3\envs\xyz\lib\site-packages\IPython\core\pylabtools.py in (fig)
246
247 if 'png' in formats:
--> 248 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
249 if 'retina' in formats or 'png2x' in formats:
250 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

~\anaconda3\envs\xyz\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
130 FigureCanvasBase(fig)
131
--> 132 fig.canvas.print_figure(bytes_io, **kw)
133 data = bytes_io.getvalue()
134 if fmt == 'svg':

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2191 else suppress())
2192 with ctx:
-> 2193 self.figure.draw(renderer)
2194
2195 bbox_inches = self.figure.get_tightbbox(

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
1862 self.patch.draw(renderer)
1863 mimage._draw_list_compositing_images(
-> 1864 renderer, self, artists, self.suppressComposite)
1865
1866 renderer.close_group('figure')

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
409 else deprecation_addendum,
410 **kwargs)
--> 411 return func(*inner_args, **inner_kwargs)
412
413 return wrapper

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\axes_base.py in draw(self, renderer, inframe)
2705 artists.remove(spine)
2706
-> 2707 self._update_title_position(renderer)
2708
2709 if not self.axison or inframe:

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\axes_base.py in _update_title_position(self, renderer)
2646 _log.debug('top of axes not in the figure, so title not moved')
2647 return
-> 2648 if title.get_window_extent(renderer).ymin < top:
2649 _, y = self.transAxes.inverted().transform((0, top))
2650 title.set_position((x, y))

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\text.py in get_window_extent(self, renderer, dpi)
900
901 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 902 bbox, info, descent = self._get_layout(self._renderer)
903 x, y = self.get_unitless_position()
904 x, y = self.get_transform().transform((x, y))

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\text.py in _get_layout(self, renderer)
287 _, lp_h, lp_d = renderer.get_text_width_height_descent(
288 "lp", self._fontproperties,
--> 289 ismath="TeX" if self.get_usetex() else False)
290 min_dy = (lp_h - lp_d) * self._linespacing
291

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\backends\backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)
226 fontsize = prop.get_size_in_points()
227 w, h, d = texmanager.get_text_width_height_descent(
--> 228 s, fontsize, renderer=self)
229 return w, h, d
230

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\texmanager.py in get_text_width_height_descent(self, tex, fontsize, renderer)
421 else:
422 # use dviread.
--> 423 dvifile = self.make_dvi(tex, fontsize)
424 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
425 page, = dvi

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\texmanager.py in make_dvi(self, tex, fontsize)
309 self._run_checked_subprocess(
310 ["latex", "-interaction=nonstopmode", "--halt-on-error",
--> 311 texfile], tex)
312 for fname in glob.glob(basefile + '*'):
313 if not fname.endswith(('dvi', 'tex')):

~\anaconda3\envs\xyz\lib\site-packages\matplotlib\texmanager.py in _run_checked_subprocess(self, command, tex)
279 raise RuntimeError(
280 'Failed to process string with tex because {} could not be '
--> 281 'found'.format(command[0])) from exc
282 except subprocess.CalledProcessError as exc:
283 raise RuntimeError(

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

`

This error can be fixed by changing the code of Utilities : https://github.com/maziarraissi/PINNs/tree/master/Utilities

@RoboticAutonomy
Copy link

you can modify this line in plotting.py:

"pgf.preamble": r"\usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc}",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants