Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >matplotlib rc('text',usetex=True)产生错误

matplotlib rc('text',usetex=True)产生错误
EN

Stack Overflow用户
提问于 2018-06-16 07:51:14
回答 1查看 2.8K关注 0票数 3

在matplotlib中使用latex渲染时遇到了问题。我遵循了https://matplotlib.org/users/usetex.html的故障排除部分中提到的所有技巧,例如清除.matplotlib/tex.cache并确保所有内容都在我的Unix路径上,但都没有用。我使用的是Spyder 3.2.8,Texlive 2018,Python 3.6,conda 4.5.4,Ghostscript 9.23和dvipng 1.15。我使用的是一台运行MacOS 10.13.2的2012 Macbook Pro。下面是一个最小的工作示例。

代码语言:javascript
运行
AI代码解释
复制
import logging
logging.basicConfig(level=logging.DEBUG)

import matplotlib.pyplot as plt
import numpy as np

plt.close("all")
plt.rc('text', usetex=True)

x=np.arange(1,10)

plt.plot(x,x)

这会产生压倒性的错误输出

代码语言:javascript
运行
AI代码解释
复制
DEBUG:matplotlib.texmanager:serif font is not compatible with usetex.
INFO:matplotlib.texmanager:No LaTeX-compatible font found for the serif font family in rcParams. Using default.
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: ('cmss', '')
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: ('pzc', '\\usepackage{chancery}')
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: ('cmtt', '')
DEBUG:matplotlib.texmanager:following keys changed: ['text.latex.preamble', 'font.family', 'font.serif', 'font.sans-serif', 'font.cursive', 'font.monospace']
DEBUG:matplotlib.texmanager:text.latex.preamble : None       -> []        
DEBUG:matplotlib.texmanager:font.family         : None       -> ['serif'] 
DEBUG:matplotlib.texmanager:font.serif          : None       -> ['Times New Roman']
DEBUG:matplotlib.texmanager:font.sans-serif     : None       -> ['DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', 'sans-serif']
DEBUG:matplotlib.texmanager:font.cursive        : None       -> ['Apple Chancery', 'Textile', 'Zapf Chancery', 'Sand', 'Script MT', 'Felipa', 'cursive']
DEBUG:matplotlib.texmanager:font.monospace      : None       -> ['DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Computer Modern Typewriter', 'Andale Mono', 'Nimbus Mono L', 'Courier New', 'Courier', 'Fixed', 'Terminal', 'monospace']
DEBUG:matplotlib.texmanager:RE-INIT
old fontconfig: serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.texmanager:serif font is not compatible with usetex.
INFO:matplotlib.texmanager:No LaTeX-compatible font found for the serif font family in rcParams. Using default.
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:sans-serif font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: ('cmss', '')
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:cursive font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: ('pzc', '\\usepackage{chancery}')
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:monospace font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: ('cmtt', '')
DEBUG:matplotlib.texmanager:fontconfig: serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.texmanager:fontconfig: serifcmrcmsspzccmttd41d8cd98f00b204e9800998ecf8427e
DEBUG:matplotlib.texmanager:['latex', '-interaction=nonstopmode', '--halt-on-error', '/Users/Ewan/.matplotlib/tex.cache/c63236ff577e7f75eb3a0878a3cae5b8.tex']
Traceback (most recent call last):
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 519, in _draw_idle
    self.draw()
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 433, in draw
    self.figure.draw(self.renderer)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/figure.py", line 1475, in draw
    renderer, self, artists, self.suppressComposite)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2607, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/axis.py", line 1192, in draw
    renderer)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/axis.py", line 1130, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/text.py", line 922, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/text.py", line 309, in _get_layout
    ismath=ismath)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 232, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/texmanager.py", line 501, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/texmanager.py", line 365, in make_dvi
    texfile], tex)
  File "/Users/Ewan/anaconda3/lib/python3.6/site-packages/matplotlib/texmanager.py", line 335, in _run_checked_subprocess
    stderr=subprocess.STDOUT)
  File "/Users/Ewan/anaconda3/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/Users/Ewan/anaconda3/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/Ewan/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/Users/Ewan/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'latex': 'latex'

编辑1:当从命令行调用时,相同的代码运行良好,甚至可以正确地呈现latex

代码语言:javascript
运行
AI代码解释
复制
plt.xlabel("$\int_0^1 \sin(\\alpha)$")
plt.show()

追加到上述示例的末尾。那么Spyder就是问题所在吗?Spyder即使在我的路径上也能找不到Latex吗?

EN

回答 1

Stack Overflow用户

发布于 2018-07-15 11:54:18

我在MacOS X 10.13.6上的jupyter notebook 4.4.0中遇到了同样的问题。只有当我自己开始使用日志记录模块时,才会出现错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50886030

复制
相关文章
IIS7 beta FREE WEBHOSTING FREE HOSTING FOR ASP.NET 2.0 IIS7[通俗易懂]
From: http://blogs.iis.net/bills/archive/2007/04/28/free-iis7-web-hosting.aspx
全栈程序员站长
2022/11/08
4.9K0
指针在函数中的作用
指针传递地址时,指针变量产生了副本,但副本与原变量所指的内存区域是同一个。对指针副本指向的变量进行改变,就是改变原指针变量所指向的变量。
跋扈洋
2022/04/27
3.1K0
指针在函数中的作用
IIS7配置thinkphp5
下载rewrite_2.0_rtw_x64.msi,在IIS7的服务器上安装,安装后,重启IIS,我是用开始-运行-iisreset重启IIS的,这时再打开IIS,会发现多了一个新的模块:
黄啊码
2020/05/29
1.5K0
IIS7配置thinkphp5
Spring Security 在 Servlet 的作用区域
Spring Security 使用标准的 Servlet 过滤器(Filter) 并与 Servlet 容器集成。 这个意味着 Spring Security 可以在任何运行运行在 Servlet 容器(Servlet Container)中的应用上使用。 更具体地说,你可以不使用 Spring,而是基于 Servlet 的应用程序中使用 Spring Security。
HoneyMoose
2022/09/30
3290
Spring Security 在 Servlet 的作用区域
虚拟变量在模型中的作用
实际场景中,有很多现象不能单纯的进行定量描述,只能用例如“出现”“不出现”这样的形式进行描述,这种情况下就需要引入虚拟变量。例如即将到来的女生节,每年的这个时候毛绒玩具的销量都会上升,说明女生节对毛绒玩具的销量产生了一定影响,但是这个影响程度又很难界定,这时只能定义一个虚拟变量去描述事情“发生”与“不发生”了。
许卉
2019/07/15
4.5K0
Lua组件在Redis中的作用
这种功能允许用户在Redis服务器上执行原子性的操作,从而避免了多次网络往返的开销。
一凡sir
2023/10/03
3620
Lua组件在Redis中的作用
WiFi在物联网中的作用
The-Role-of-Wi-Fi-in-the-IoT-Space-1536x944-1.jpg
用户4122690
2020/06/28
1.8K0
WiFi在物联网中的作用
ZooKeeper在HBase集群中的作用
ZooKeeper作为分布式协调组件,在大数据领域的其他分布式组件中往往扮演着重要的辅助角色,因此我们就算不单独去研究ZooKeeper,也短不了要接触它。本文就以最典型的HBase为例,简要介绍ZooKeeper为HBase提供了哪些功能。
Flink实战剖析
2022/04/20
1.5K0
ZooKeeper在HBase集群中的作用
Etcd在kubernetes集群中的作用
Etcd是Kubernetes集群中的一个十分重要的组件,用于保存集群所有的网络配置和对象的状态信息。在后面具体的安装环境中,我们安装的etcd的版本是v3.1.5,整个kubernetes系统中一共有两个服务需要用到etcd用来协同和存储配置,分别是:
菲宇
2019/06/12
3.8K0
AI在抗击疫情中的作用
这几十年以来,肆虐全球的新冠病毒可以说是最具感染性了。正如我们目前所见,新冠病毒已经给全世界造成了极大的破坏,因此,借助科技的力量抵抗疫情也变得十分必要。AI就是我们要说的重要的科技手段。本文将讨论AI在抗击新冠疫情中的重要作用。
人工智能小咖
2020/04/16
1.3K0
AI在抗击疫情中的作用
Redis在秒杀场景的作用
秒杀可分成秒杀前、秒杀中和秒杀后三阶段,每个阶段的请求处理需求不同,Redis具体在秒杀场景的哪个环节起到作用呢?
JavaEdge
2023/02/13
7830
Redis在秒杀场景的作用
KubeEdge及其在MEC中的作用
KubeEdge是一个云原生计算基金会(CNCF)sandbox项目,旨在将Kubernetes从云扩展到边缘。它提供了基础架构支持,以支持在边缘节点上部署和编排云原生服务,以及边缘与云之间元数据的同步。
CNCF
2020/07/16
1.7K0
IIS7的应用程序池
最近将原来的系统迁移到IIS7.5上了,发现AspNetUpload只能运行在"程序程序池"的"经典"模式之下,采用"集成"模式后,AspnetUpload.GetUploadFile始终为null,虽然改成经典不影响系统运行,但是这种模式就发挥不出IIS7的优势了,相当于以IIS6的兼容模式在运行,不知道作者会不会改进。 以下是MDSN上的关于应用程序池"集成"与"经典"模式的解释:(http://technet.microsoft.com/zh-cn/library/cc753449(WS.10).
菩提树下的杨过
2018/01/23
1.4K0
spring在ssh框架中的作用学习
spring在ssh框架中的作用学习 在SSH框假中spring充当了管理容器的角色。我们都知道Hibernate用来做持久层,因为它将JDBC做了一个良好的封装,程序员在与数据库进行交互时可以不用书写大量的SQL语 句。Struts是用来做应用层的,他它负责调用业务逻辑serivce层。所以SSH框架的流程大致是:Jsp页面—-Struts——Service(业务逻辑处理类)—Hibernate(左到右) struts负责控制Service(业务逻辑处理类),从而控制了Service的生命
用户1289394
2018/02/26
1.2K0
【夯实基础】Spring在ssh中的作用
尊重版权:http://blog.csdn.net/qjlsharp/archive/2009/03/21/4013255.aspx
全栈程序员站长
2022/07/07
7040
浅析:外链在SEO中的作用!
长期以来,外链在SEO工作都是一个不可逾越的话题,它在整站优化中,扮演重要的角色,特别是熊掌号上线,很多SEO人员,逐渐在唱衰外链的作用。
蝙蝠侠IT
2019/07/15
8190
浅析:外链在SEO中的作用!
Hbase在HDFS上的各个目录作用
1、/hbase/.META. 就是存储1中介绍的 META 表的存储路径。 2、/hbase/.archive HBase 在做 Split或者 compact 操作完成之后,会将 HFile 移到.archive 目录中,然后将之前的 hfile 删除掉,该目录由 HMaster 上的一个定时任务定期去清理。 3、/hbase/.corrupt 存储HBase做损坏的日志文件,一般都是为空的。 4、/hbase/.hbck HBase 运维过程中偶尔会遇到元数据不一致的情况,这时候会用到提供的 hbck 工具去修复,修复过程中会使用该目录作为临时过度缓冲。 5、/hbase/WAL 大家都知道 HBase 是支持 WAL(Write Ahead Log) 的,HBase 会在第一次启动之初会给每一台 RegionServer 在.log 下创建一个目录,若客户端如果开启WAL 模式,会先将数据写入一份到.log 下,当 RegionServer crash 或者目录达到一定大小,会开启 replay 模式,类似 MySQL 的 binlog。 6、/hbase/oldlogs 当.logs 文件夹中的 HLog 没用之后会 move 到.oldlogs 中,HMaster 会定期去清理。 7、/hbase/.snapshot hbase若开启了 snapshot 功能之后,对某一个用户表建立一个 snapshot 之后,snapshot 都存储在该目录下,如对表test 做了一个 名为sp_test 的snapshot,就会在/hbase/.snapshot/目录下创建一个sp_test 文件夹,snapshot 之后的所有写入都是记录在这个 snapshot 之上。 8、/hbase/.tmp 当对表做创建或者删除操作的时候,会将表move 到该 tmp 目录下,然后再去做处理操作。 9、/hbase/hbase.id 它是一个文件,存储集群唯一的 cluster id 号,是一个 uuid。 10、/hbase/hbase.version 同样也是一个文件,存储集群的版本号,貌似是加密的,看不到,只能通过web-ui 才能正确显示出来。
shengjk1
2018/10/24
2.9K0
硫原子在药物设计中的作用
缺电子的二价硫原子具有两个正电势区域,可以与氮、氧或者π体系这些电子供体形成类似氢键的作用,这种相互作用广泛存在于天然产物和药物分子中,硫原子对于调节分子的构象和活性具有令人欣喜的效果。
智药邦
2023/02/15
1.1K0
硫原子在药物设计中的作用
在 Android 和 Hilt 中限定作用域
将对象 A 的作用域限定到对象 B,指的是对象 B 的整个生命周期内始终持有相同的 A 实例。当涉及到 DI (依赖项注入) 时,限定对象 A 的作用域为一个容器,则意味着该容器在销毁之前始终提供相同的 A 实例。
Android 开发者
2020/11/16
1.5K0
在 Android 和 Hilt 中限定作用域
点击加载更多

相似问题

httpModules在iis7上不起作用

30

ActionMethodSelectorAttribute在IIS7上不起作用

21

AJAX/UpdatePanel在IIS7上不起作用

24

jQuery在Windows Server2008、IIS7上不起作用

17

Wordpress url重写在iis7上不起作用

11
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档