2012-07-05 86 views
27

我最近將我的筆記本電腦升級到Snow Leopard,TeX升級到版本3.1415926(TeX Live 2011/MacPorts 2011_5),並安裝了Python 2.7.3。完成所有這些安裝後,我運行macport selfupdate和macport upgrade過期。但是,現在當我嘗試在matplotlib使用TeX的,我收到以下內容:Python:無法渲染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. 

類似this previous question,我試圖通過設置在我的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),這是不理想的。任何幫助將非常感激。

+3

這個固定爲我'sudo易於得到我的Ubuntu 13.10的機器上安裝dvipng' – 2016-07-06 23:41:21

回答

34

錯誤消息說您錯過了type1cm包。看來MacPorts includes it as part of texlive-latex-extra

+2

仍然適用。我還需要dvipng軟件包。 – travc 2014-02-12 19:53:20

+3

在ubuntu 14.04.1上,我需要安裝'texlive-latex-extra'和'texlive-fonts-recommended' – 2015-01-11 12:00:39

+0

在Ubuntu 15.10上也是一樣的......但是,matplotlib繼續使用**安裝前生成的緩存版本**這些包。在安裝這些軟件包之前,matplotlib會生成沒有文本的圖。我花了一點時間才意識到正在使用緩存版本,但是在〜/ .cache/matplotlib/tex.cache /中刪除了dvi和pdf。 – 2016-02-07 14:21:22

17

在Ubunutu 14.04機器上面的答案組合工作。我sudo apt-get installdvipngtexlive-latex-extra,並且texlive-fonts-recommended包和沒有的伎倆:

$ sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended 
+4

也適用於Ubuntu16.04。 – 2016-12-27 20:06:57

+1

也適用於Linux的Windows子系統中的Ubuntu 16.04.1。 – theCake 2017-04-08 01:45:18