manim: Exception: Latex error converting to dvi. See log output above...

Let me start by saying that I’ve read through all of the other issues on here with the same error message, and have tried each of the fixes, but to no avail.

I was running example scene #1, and:

Traceback (most recent call last):
  File "C:\Users\kaneo\Desktop\manim\manim\manimlib\extract_scene.py", line 155, in main
    scene = SceneClass(**scene_kwargs)
  File "C:\Users\kaneo\Desktop\manim\manim\manimlib\scene\scene.py", line 52, in __init__
    self.construct()
  File "example_scenes.py", line 18, in construct
    title = TextMobject("This is some \\LaTeX")
  File "C:\Users\kaneo\Desktop\manim\manim\manimlib\mobject\svg\tex_mobject.py", line 145, in __init__
    self, self.arg_separator.join(tex_strings), **kwargs
  File "C:\Users\kaneo\Desktop\manim\manim\manimlib\mobject\svg\tex_mobject.py", line 45, in __init__
    self.template_tex_file_body
  File "C:\Users\kaneo\Desktop\manim\manim\manimlib\utils\tex_file_writing.py", line 19, in tex_to_svg_file
    dvi_file = tex_to_dvi(tex_file)
  File "C:\Users\kaneo\Desktop\manim\manim\manimlib\utils\tex_file_writing.py", line 67, in tex_to_dvi
    "See log output above or the log file: %s" % log_file)
Exception: Latex error converting to dvi. See log output above or the log file: C:\Users\kaneo\Desktop\manim\manim\manimlib\files\Tex\cc8b128e228b77ce.log

The ‘log file’ contains:

`\documentclass[preview]{standalone}

\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{microtype}
\DisableLigatures{encoding = *, family = * }
%\usepackage[UTF8]{ctex}
\linespread{1}

\begin{document}

\centering This is some \LaTeX

\end{document}`

I’m on windows 10. This same error happens when I make my own custom scripts, but I am able to run example scenes 2 and 4.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 34 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I met the same problem. I’m using Windows 10, and found it caused by TeX engines. In Windows, path seqerator is \ but TeX recognized it as a escape character. eg. ./media\Tex\fjkaljfa.tex will be ./mediaexjkaljfa.tex, the \T, \f have been wiped.

So replace \ to / before calling a TeX executable will solve this problem.

diff --git a/manimlib/utils/tex_file_writing.py b/manimlib/utils/tex_file_writing.py
index 5df24de3..d8bbdad1 100644
--- a/manimlib/utils/tex_file_writing.py
+++ b/manimlib/utils/tex_file_writing.py
@@ -1,6 +1,8 @@
 import os
 import hashlib
 
+from pathlib import Path
+
 from manimlib.constants import TEX_TEXT_TO_REPLACE
 from manimlib.constants import TEX_USE_CTEX
 import manimlib.constants as consts
@@ -39,12 +41,15 @@ def generate_tex_file(expression, template_tex_file_body):
 
 def tex_to_dvi(tex_file):
     result = tex_file.replace(".tex", ".dvi" if not TEX_USE_CTEX else ".xdv")
+    result = Path(result).as_posix()
+    tex_file = Path(tex_file).as_posix()
+    tex_dir = Path(consts.TEX_DIR).as_posix()
     if not os.path.exists(result):
         commands = [
             "latex",
             "-interaction=batchmode",
             "-halt-on-error",
-            "-output-directory=\"{}\"".format(consts.TEX_DIR),
+            "-output-directory=\"{}\"".format(tex_dir),
             "\"{}\"".format(tex_file),
             ">",
             os.devnull
@@ -53,7 +58,7 @@ def tex_to_dvi(tex_file):
             "-no-pdf",
             "-interaction=batchmode",
             "-halt-on-error",
-            "-output-directory=\"{}\"".format(consts.TEX_DIR),
+            "-output-directory=\"{}\"".format(tex_dir),
             "\"{}\"".format(tex_file),
             ">",
             os.devnull
@@ -76,6 +81,8 @@ def dvi_to_svg(dvi_file, regen_if_exists=False):
     where in the dvi
     """
     result = dvi_file.replace(".dvi" if not TEX_USE_CTEX else ".xdv", ".svg")
+    result = Path(result).as_posix()
+    dvi_file = Path(dvi_file).as_posix()
     if not os.path.exists(result):
         commands = [
             "dvisvgm",

Did someone PR it?

I’m facing the exact same issue; when I try to run python -m manim example_scenes.py WriteStuff -pl, I get “See log output above…” with “Latex error converting to dvi.” However, there is no log file ./media\Tex\e6984177d9d09224.log as indicated, only a .tex file of the same name. I have Tex Live installed and all the appropriate packages (I know this because I successfully managed to compile the .tex file independently). What’s going on?

Is your \manim folder in a folder path that has a folder name with a space? That ended up being my issue. LaTeX works fine now.

Hey there, I had the similar problem. None of the above worked because my problem was somewhere else,

I had the similar issue, here, basically the error message means there is some error compiling the tex.

If you have several lines of text, then check the .tex file made after trying to compile the code. Mine was c2f123b87baffd8.tex. Now check the code, I found it had,

\begin{align*} $$\text{Hello}$$ \end{align*}

certainly this is scandal if you know latex, I went to the .py file immediately and removed the $$ from the text. This later solved my issue.

I hope this helps

Try to change

\usepackage[english]{babel}

by

\usepackage[utf8]{inputenc}

in manimlib/tex_template.tex (line 3)

You’re using latex inside a TextMobject. Use a TexMobject instead.

use MathTex(r" your Latex") or TexMobject(r" ur latex") it will surely work😄

Instead of using Tex(for community version) or TexMobject simply use MathTex. See if this resolves your issue.

I was able to solve this problem by doing a full install of Latex in Ubuntu:

sudo apt-get install texlive-full

Hope it helps!

I had same problem and I tried all the solution listed above but didn’t worked for me. I came to know that error was due to some missing packages. I uninstalled MikTex and installed again but chose to install missing packages on the fly while installing.

Screenshot (4)

It worked fine for me.

I found what needed to be fixed for this issue on my machine! Windows only takes double quotes around paths, so at line 47, 48, 56, 57, 82, 87 of manimlib/utils/tex_file_writing.py replace the escaped single quotes with double quotes If this doesn’t impede development on other OS it should be corrected on master_branch

It sounds like you don’t have LateX installed. Go to the LaTeX project website and download the suggested distribution for your OS.