我最近将我的笔记本电脑升级到了 Snow Leopard,更新了 TeX 到 3.1415926 版本 (TeX Live 2011/MacPorts 2011_5),同时安装了 Python 2.7.3。在这些安装完成后,我运行了 macport selfupdate 和 macport upgrade outdated。但是,现在当我尝试在 matplotlib 中使用 TeX 时,我收到了以下错误信息:
LaTeX was not able to process the following string:'lp'
Here is the full report generated by LaTeX:
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011/MacPorts 2011_5)
restricted \write18 enabled.
entering extended mode (./64a53cc27244d5ee10969789771e33fa.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, cz
ech, slovak, dutch, ukenglish, usenglishmax, basque, french, german-x-2009-06-1
9, ngerman-x-2009-06-19, german, ngerman, swissgerman, italian, polish, portugu
ese, spanish, catalan, galician, ukenglish, loaded.
(/opt/local/share/texmf-texlive-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/opt/local/share/texmf-texlive-dist/tex/latex/base/size10.clo))
! LaTeX Error: File `type1cm.sty' not found.
Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty)
l.3 \renewcommand
{\rmdefault}{pnc}^^M
No pages of output.
与此前的问题类似,我尝试通过以下方式在我的Python代码中设置路径:
os.environ['PATH'] = os.environ['PATH'] + ':/opt/local/bin/latex'
由于which latex
的结果是/opt/local/bin/latex
,然而尝试使用该命令时却出现了相同的错误信息。我还尝试了tex的路径以及上一个问题中的示例,但都无济于事。
然后我尝试通过强制安装可能缺失的软件包来解决问题:
matplotlib.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]
但是,那也没有起作用。
我唯一能让我的图表工作的方式是使用rc('text', usetex=False)
,这不是理想的。非常感谢任何帮助。
sudo apt-get install dvipng
对我很有用。 - Alexander McFarlane