我正在尝试执行这个确切的代码multipage pdf,在Ipython上复制%paste,ubuntu14.04,python 2.7.6
我收到以下错误
RuntimeError: LaTeX was not able to process the following string:
'lp'
完整追溯
sh: 1: latex: not found
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-e46ddc0d5d7d> in <module>()
19 plt.plot(x, np.sin(x), 'b-')
20 plt.title('Page Two')
---> 21 pdf.savefig()
22 plt.close()
23
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.pyc in savefig(self, figure, **kwargs)
2439 else:
2440 figureManager.canvas.figure.savefig(self, format='pdf',
-> 2441 **kwargs)
2442
2443 def get_pagecount(self):
/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs)
1474 self.set_frameon(frameon)
1475
-> 1476 self.canvas.print_figure(*args, **kwargs)
1477
1478 if frameon:
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5agg.pyc in print_figure(self, *args, **kwargs)
159
160 def print_figure(self, *args, **kwargs):
--> 161 FigureCanvasAgg.print_figure(self, *args, **kwargs)
162 self.draw()
163
/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2209 orientation=orientation,
2210 bbox_inches_restore=_bbox_inches_restore,
-> 2211 **kwargs)
2212 finally:
2213 if bbox_inches and restore_bbox:
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.pyc in print_pdf(self, filename, **kwargs)
2483 RendererPdf(file, image_dpi),
2484 bbox_inches_restore=_bbox_inches_restore)
-> 2485 self.figure.draw(renderer)
2486 renderer.finalize()
2487 finally:
/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
57 def draw_wrapper(artist, renderer, *args, **kwargs):
58 before(artist, renderer)
---> 59 draw(artist, renderer, *args, **kwargs)
60 after(artist, renderer)
61
/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)
1083 dsu.sort(key=itemgetter(0))
1084 for zorder, a, func, args in dsu:
-> 1085 func(*args)
1086
1087 renderer.close_group('figure')
/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
57 def draw_wrapper(artist, renderer, *args, **kwargs):
58 before(artist, renderer)
---> 59 draw(artist, renderer, *args, **kwargs)
60 after(artist, renderer)
61
/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
2108
2109 for zorder, a in dsu:
-> 2110 a.draw(renderer)
2111
2112 renderer.close_group('axes')
/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
57 def draw_wrapper(artist, renderer, *args, **kwargs):
58 before(artist, renderer)
---> 59 draw(artist, renderer, *args, **kwargs)
60 after(artist, renderer)
61
/usr/local/lib/python2.7/dist-packages/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
1114 ticks_to_draw = self._update_ticks(renderer)
1115 ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
-> 1116 renderer)
1117
1118 for tick in ticks_to_draw:
/usr/local/lib/python2.7/dist-packages/matplotlib/axis.pyc in _get_tick_bboxes(self, ticks, renderer)
1063 for tick in ticks:
1064 if tick.label1On and tick.label1.get_visible():
-> 1065 extent = tick.label1.get_window_extent(renderer)
1066 ticklabelBoxes.append(extent)
1067 if tick.label2On and tick.label2.get_visible():
/usr/local/lib/python2.7/dist-packages/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
796 raise RuntimeError('Cannot get window extent w/o renderer')
797
--> 798 bbox, info, descent = self._get_layout(self._renderer)
799 x, y = self.get_position()
800 x, y = self.get_transform().transform_point((x, y))
/usr/local/lib/python2.7/dist-packages/matplotlib/text.pyc in _get_layout(self, renderer)
309 tmp, lp_h, lp_bl = renderer.get_text_width_height_descent('lp',
310 self._fontproperties,
--> 311 ismath=False)
312 offsety = (lp_h - lp_bl) * self._linespacing
313
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.pyc in get_text_width_height_descent(self, s, prop, ismath)
2042 fontsize = prop.get_size_in_points()
2043 w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
-> 2044 renderer=self)
2045 return w, h, d
2046
/usr/local/lib/python2.7/dist-packages/matplotlib/texmanager.pyc in get_text_width_height_descent(self, tex, fontsize, renderer)
668 else:
669 # use dviread. It sometimes returns a wrong descent.
--> 670 dvifile = self.make_dvi(tex, fontsize)
671 dvi = dviread.Dvi(dvifile, 72 * dpi_fraction)
672 try:
/usr/local/lib/python2.7/dist-packages/matplotlib/texmanager.pyc in make_dvi(self, tex, fontsize)
415 'string:\n%s\nHere is the full report generated by '
416 'LaTeX: \n\n' % repr(tex.encode('unicode_escape')) +
--> 417 report))
418 else:
419 mpl.verbose.report(report, 'debug')
有什么猜测这个运行时错误有什么问题? 因为我实际上可以从matplotlib导入rc。
答案 0 :(得分:2)
如果有人处于相同的情况我会发布答案, 显然乳胶已安装,但matplotlib没有找到路径, 我按如下方式重建了所有环境:
更新deb存储库
sudo apt-get update
这会输出关于ipython的乳胶报告
sudo apt-get install texlive-latex-extra
最后重建所有
sudo apt-get install dvipng
sudo apt-get build-dep python-matplotlib