如何解决如何在Paperspace Gradient中使用LaTeX字体?
我想在Gradient上的jupyter笔记本中使用带有matplotlib图的LaTeX字体,但是我无法像在本地系统上那样创建乳胶mplstyle文件。我认为问题在于此云系统上未安装LaTeX。有没有办法在基于云的平台上安装LaTeX?这是我尝试更改matplotlib的mlpstyle参数以使用tex并使用乳胶字体绘制图表时得到的错误。
FileNotFoundError Traceback (most recent call last) /opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(self,command,tex)
274 try:
--> 275 report = subprocess.check_output(command,276 cwd=self.texcache,/opt/conda/envs/fastai/lib/python3.8/subprocess.py in check_output(timeout,*popenargs,**kwargs)
410
--> 411 return run(*popenargs,stdout=PIPE,timeout=timeout,check=True,412 **kwargs).stdout
/opt/conda/envs/fastai/lib/python3.8/subprocess.py in run(input,capture_output,timeout,check,**kwargs)
488
--> 489 with Popen(*popenargs,**kwargs) as process:
490 try:
/opt/conda/envs/fastai/lib/python3.8/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,text)
853
--> 854 self._execute_child(args,855 pass_fds,/opt/conda/envs/fastai/lib/python3.8/subprocess.py in
_execute_child(self,p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite,start_new_session) 1701 err_msg = os.strerror(errno_num)
-> 1702 raise child_exception_type(errno_num,err_msg,err_filename) 1703 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last) <ipython-input-45-1b9c79a562c2> in <module>
4 plt.ylabel('Loss',fontsize=20)
5 plt.legend(fontsize=10)
----> 6 fig256.savefig('what.pdf',dpi=400,bbox_inches='tight')
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/figure.py in savefig(self,fname,transparent,**kwargs) 2309 patch.set_edgecolor('none') 2310
-> 2311 self.canvas.print_figure(fname,**kwargs) 2312 2313 if transparent:
/opt/conda/envs/fastai/lib/python3.8/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(
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/artist.py in draw_wrapper(artist,renderer,*args,**kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist,**kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/figure.py in draw(self,renderer) 1861 1862 self.patch.draw(renderer)
-> 1863 mimage._draw_list_compositing_images( 1864 renderer,self,artists,self.suppressComposite) 1865
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer,parent,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
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/artist.py in draw_wrapper(artist,**kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
/opt/conda/envs/fastai/lib/python3.8/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
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/axes/_base.py in draw(self,inframe) 2746 renderer.stop_rasterizing() 2747
-> 2748 mimage._draw_list_compositing_images(renderer,artists) 2749 2750 renderer.close_group('axes')
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer,**kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/axis.py in draw(self,**kwargs) 1163 1164 ticks_to_draw = self._update_ticks()
-> 1165 ticklabelBoxes,ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,1166 renderer) 1167
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/axis.py in _get_tick_bboxes(self,ticks,renderer) 1089 def
_get_tick_bboxes(self,renderer): 1090 """Return lists of bboxes for ticks' label1's and label2's."""
-> 1091 return ([tick.label1.get_window_extent(renderer) 1092 for tick in ticks if tick.label1.get_visible()],1093 [tick.label2.get_window_extent(renderer)
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/axis.py in <listcomp>(.0) 1089 def _get_tick_bboxes(self,1093 [tick.label2.get_window_extent(renderer)
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/text.py in get_window_extent(self,dpi)
898
899 with cbook._setattr_cm(self.figure,dpi=dpi):
--> 900 bbox,info,descent = self._get_layout(self._renderer)
901 x,y = self.get_unitless_position()
902 x,y = self.get_transform().transform((x,y))
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/text.py in _get_layout(self,renderer)
283
284 # Full vertical extent of font,including ascenders and descenders:
--> 285 _,lp_h,lp_d = renderer.get_text_width_height_descent(
286 "lp",self._fontproperties,287 ismath="TeX" if self.get_usetex() else False)
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/backends/_backend_pdf_ps.py in get_text_width_height_descent(self,s,prop,ismath)
84 texmanager = self.get_texmanager()
85 fontsize = prop.get_size_in_points()
---> 86 w,h,d = texmanager.get_text_width_height_descent(
87 s,fontsize,renderer=self)
88 return w,d
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/texmanager.py in get_text_width_height_descent(self,tex,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
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/texmanager.py in make_dvi(self,fontsize)
307 texfile = self.make_tex(tex,fontsize)
308 with cbook._lock_path(texfile):
--> 309 self._run_checked_subprocess(
310 ["latex","-interaction=nonstopmode","--halt-on-error",311 texfile],tex)
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(self,tex)
277 stderr=subprocess.STDOUT)
278 except FileNotFoundError as exc:
--> 279 raise RuntimeError(
280 'Failed to process string with tex because {} could not be '
281 'found'.format(command[0])) from exc
RuntimeError: Failed to process string with tex because latex could not be found
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) /opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(self,err_filename) 1703 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last) /opt/conda/envs/fastai/lib/python3.8/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)
/opt/conda/envs/fastai/lib/python3.8/site-packages/IPython/core/pylabtools.py in <lambda>(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))
/opt/conda/envs/fastai/lib/python3.8/site-packages/IPython/core/pylabtools.py in print_figure(fig,fmt,**kwargs)
130 FigureCanvasBase(fig)
131
--> 132 fig.canvas.print_figure(bytes_io,**kw)
133 data = bytes_io.getvalue()
134 if fmt == 'svg':
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/backend_bases.py in print_figure(self,287 ismath="TeX" if self.get_usetex() else False)
/opt/conda/envs/fastai/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py in get_text_width_height_descent(self,ismath)
225 texmanager = self.get_texmanager()
226 fontsize = prop.get_size_in_points()
--> 227 w,d = texmanager.get_text_width_height_descent(
228 s,renderer=self)
229 return w,tex)
277 stderr=subprocess.STDOUT)
278 except FileNotFoundError as exc:
--> 279 raise RuntimeError(
280 'Failed to process string with tex because {} could not be '
281 'found'.format(command[0])) from exc
RuntimeError: Failed to process string with tex because latex could not be found
<Figure size 576x396 with 1 Axes>
'''
Does somebody know a workaround?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。