Mac OS X 和 TeX Live 上 matplotlib 中的 TeX
我有以下 Hello World 代码来在我的 Mac 上尝试使用 matplotlib 进行 TeX 渲染。
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()
使用该代码,我会收到以下错误:
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。
我尝试将 /Library/TeX/Root/bin/universal-darwin
添加到项目属性的全局 Python 路径,但仍然遇到相同的错误。
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:
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将来您可能会提到您正在从 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'ssys.path
, the path from which Python code is loaded. You need to setos.environ['PATH']
in your Python code; with TeX Live the preferred way to reference the current TeX installation is/usr/texbin
.