如何在Paperspace Gradient中使用LaTeX字体?

如何解决如何在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 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-