Spyder在渲染Sympy矩阵时无法渲染乳胶

时间:2015-11-18 23:02:21

标签: python sympy spyder

Python 3.5.0 | Anaconda 2.4.0(x86_64) Python 4.0.0 Spyder今天更新了。 在Mac iBook OS 10.10.1上运行

>>> M = Matrix([[1, 0, 1, 3], [2, 3, 4, 7], [-1, -3, -3, -4]])
>>> M

在Spyder内部控制台中产生以下错误:

>>> /Users/webe077/anaconda/lib/python3.5/site-packages/nbformat/current.py:19: UserWarning: nbformat.current is deprecated.

- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version

  """)
ERROR:root:Failed to render latex: '$$\left ( \left[\begin{matrix}1 & 0 & 1 & 3\\0 & 1 & \frac{2}{3} & \frac{1}{3}\\0 & 0 & 0 & 0\end{matrix}\right], \quad \left [ 0, \quad 1\right ]\right )$$'
pyparsing.ParseException: Expected "\right" (at char 14), (line:1, col:15)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/webe077/anaconda/lib/python3.5/site-packages/matplotlib/mathtext.py", line 2333, in parse...

该示例在Sympy Web工具

中正常工作

2 个答案:

答案 0 :(得分:4)

我最近遇到了同样的问题,并且已经通过moorepants在topic解决了这个问题。

总而言之,您必须在计算机上安装dvipng库,因此sympy不依赖于matplotlib来渲染乳胶矩阵,这是无效的。 我已经安装了包含miktex的{​​{1}},如果您愿意,可以找到另一个。{1}}。 然后,重新启动spyder并显示矩阵。出现一个窗口,警告您已加载外部包。点击“确定”,它应该可以工作。

答案 1 :(得分:0)

如果您安装了乳胶,请尝试

init_printing(use_latex=True)

而不是

init_printing(use_latex='mathjax')