本文介绍了OSX 10.8中usetex的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到OSX 10.8(Mountain Lion),如果我尝试在地块标签中使用乳胶标记,则我的python安装现在行为异常.

I recently upgraded to OSX 10.8 (Mountain Lion) and my python install is now misbehaving if I try to use latex mark-up in my plot labels.

以下代码可以完美运行:

The following code runs perfectly:

plt.figure()
plt.plot( rand(51), rand(51) )
plt.show()

但是,这不是:

plt.rc( 'text', usetex=True )
plt.figure()
plt.plot( rand(51), rand(51) )
plt.show()

我得到的错误是:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/wx/_misc.py", line 1342, in Notify
    self.notify()
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/wx/_core.py", line 14716, in Notify
    self.result = self.callable(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py", line 990, in _onDrawIdle
    self.draw(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py", line 59, in draw
    FigureCanvasAgg.draw(self)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 401, in draw
    self.figure.draw(self.renderer)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/figure.py", line 884, in draw
    func(*args)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/axes.py", line 1983, in draw
    a.draw(renderer)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/axis.py", line 1037, in draw
    ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/axis.py", line 988, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/text.py", line 747, in get_window_extent
    bbox, info = self._get_layout(self._renderer)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/text.py", line 300, in _get_layout
    ismath=False)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 174, in get_text_width_height_descent
    renderer=self)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/texmanager.py", line 608, in get_text_width_height_descent
    page = iter(dvi).next()
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 65, in __iter__
    have_page = self._read()
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 121, in _read
    self._dispatch(byte)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 209, in _dispatch
    self._fnt_def(k, c, s, d, a, l, n)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 362, in _fnt_def
    tfm = _tfmfile(n[-l:])
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 878, in _tfmfile
    return _fontfile(texname, Tfm, '.tfm', _tfmcache)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 868, in _fontfile
    filename = find_tex_file(texname + suffix)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/matplotlib/dviread.py", line 838, in find_tex_file
    pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

还有其他人遇到过此问题吗?我该如何解决?

Has anyone else encountered this problem? How do I fix this?

推荐答案

也许TeX和实用程序不在您的$PATH上?您应该进行设置,以便在命令行上键入"tex"或"kpsewhich"时,您可以调用这些程序(即获得一些输出,而不是找不到命令").如果您以前安装了TeX Live,请确保/usr/texbin在搜索路径中.

Maybe TeX and utilities are not on your $PATH? You should set things up so that if you type "tex" or "kpsewhich" on the command line, you invoke those programs (i.e. get some output instead of "command not found"). If you installed TeX Live previously, make sure that /usr/texbin is in the search path.

这篇关于OSX 10.8中usetex的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 06:05