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

问题描述

我有以下Hello World代码,可以在Mac上使用matplotlib尝试TeX渲染.

I have the following Hello World code to try out TeX rendering with matplotlib on my Mac.

import matplotlib.pyplot as plt
from matplotlib import rc

rc('text', usetex=True)
rc('font', family='serif')

plt.text(2,2,r"Hello World!")
plt.show()

使用该代码,我将收到以下错误:

With that code, I'd get the following error:

sh: latex: command not found
Exception in Tkinter callback
<... a long Traceback here ...>
RuntimeError: LaTeX was not able to process the following string:
'lp'
Here is the full report generated by LaTeX:

在最后一行之后,我看不到任何完整的报告.无论如何,我认为这是一个路径问题.关于如何解决该问题的一些建议?我有TeX Live 2010.

I don't see any kind of full report after the last line. Anyway, I think this is a path problem. Some pointers on how I could fix it? I have TeX Live 2010.

我尝试将/Library/TeX/Root/bin/universal-darwin添加到项目属性"的全局Python路径",但是仍然出现相同的错误.

I tried adding /Library/TeX/Root/bin/universal-darwin to the Global Python Path of the Project Properties, but I still get the same errors.

推荐答案

将来,您可能要提到您正在从NetBeans运行代码. Python路径不是$PATH,而是sys.path,即从中加载Python代码的路径.您需要在Python代码中设置os.environ['PATH'];使用TeX Live引用当前TeX安装的首选方法是/usr/texbin.

In future you might want to mention that you're running the code from NetBeans. The Python path is not $PATH, instead it's sys.path, the path from which Python code is loaded. You need to set os.environ['PATH'] in your Python code; with TeX Live the preferred way to reference the current TeX installation is /usr/texbin.

这篇关于Mac OS X和TeX Live上matplotlib中的TeX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 03:36