TeX in matplotlib on Mac OS X and TeX Live

匿名 (未验证) 提交于 2019-12-03 02:24:01

问题:

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.

回答1:

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.



回答2:

Just change:

rc('text', usetex=True)

to:

rc('text', usetex=False)


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!