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

RSW*_*RSW 2 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
Run Code Online (Sandbox Code Playgroud)

在 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...
Run Code Online (Sandbox Code Playgroud)

该示例在 Sympy Web 工具中运行良好

小智 5

我最近遇到了同样的问题, moorepants解决了这个问题。

总而言之,您必须dvipng在计算机上安装该库,以便sympy不依赖于matplotlib渲染乳胶矩阵,这是行不通的。我已经安装了miktex其中包括dvipng,如果你想要的话,你可以找到另一个。然后,重新启动spyder并显示矩阵。将出现一个窗口,警告您已加载外部包。单击“确定”,它应该可以工作。