Manim 的问题。 'error converting to dvi.'
Issues with Manim. 'error converting to dvi.'
我正在尝试使用 Manim(Youtuber 3Blue1Brown python 的库)制作动画。我已经安装了必要的软件,包括最新版本的 MikTex 和 python。我可以 运行 SquareToCircle 动画,但是每当我尝试 运行 任何涉及文本的动画时,我都会收到以下错误:
Exception: Latex error converting to dvi. See log output above or the log file: C:\Animation Programs\Manim\manim_3_feb\manimlib\files\Texf78a457bde38f5.log
没有这样的 .log 文件,但是在完全相同的文件夹中有一个名称完全相同的 .tex 文件。 .tex 文件读取(在记事本中打开)
\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}
这个问题似乎在 the following post 中的一些人那里得到了解决,建议我 "change the commands = [...] in mobject/tex_mobject.py",但是在任何地方都没有 'command' 行tex_mobject.py 文件。
我复制了以下函数(显然应该已经存在于文件中,但没有)并将它们粘贴到 tex_mobject.py
def tex_to_dvi(tex_file):
result = tex_file.replace(".tex", ".dvi")
if not os.path.exists(result):
commands = [
"latex",
"-interaction=batchmode",
"-halt-on-error",
"-output-directory=" + TEX_DIR,
tex_file,
]
exit_code = os.system(" ".join(commands))
if exit_code != 0:
latex_output = ''
log_file = tex_file.replace(".tex", ".log")
if os.path.exists(log_file):
with open(log_file, 'r') as f:
latex_output = f.read()
if latex_output:
sys.stderr.write(latex_output)
raise Exception(
"Latex error converting to dvi. "
"See log output above or the log file: %s" % log_file)
return result
.
def dvi_to_svg(dvi_file, regen_if_exists = False):
"""
Converts a dvi, which potentially has multiple slides, into a
directory full of enumerated pngs corresponding with these slides.
Returns a list of PIL Image objects for these images sorted as they
where in the dvi
"""
result = dvi_file.replace(".dvi", ".svg")
if not os.path.exists(result):
commands = [
"dvisvgm",
dvi_file,
"-n",
"-v",
"0",
"-o",
result,
]
os.system(" ".join(commands))
return result
但我仍然遇到同样的错误。
在同一个 post 中,其他人建议查看引用的 .log 文件,因为这会让我知道是否缺少任何包。正如我所说,我没有这样的 .log 文件,相应的 .tex 文件似乎没有提到任何丢失的包。
非常感谢任何帮助!
该答案现在不再有用,因为 Manim 已经解决了该问题。所以这可能是由于两件事:
为了提示我们哪里出了问题,请使用终端转到 manimlib 文件夹,然后 运行 以下内容:
latex tex_template.tex
我们区分两种可能的错误:
识别到latex命令但是编译无法完成,因为你缺少库,要解决这个问题你可以安装终端指示缺少的包。
LaTeX 没有被识别为命令,在这种情况下肯定是 PATH 变量设置不正确,here is the solution.
我正在尝试使用 Manim(Youtuber 3Blue1Brown python 的库)制作动画。我已经安装了必要的软件,包括最新版本的 MikTex 和 python。我可以 运行 SquareToCircle 动画,但是每当我尝试 运行 任何涉及文本的动画时,我都会收到以下错误:
Exception: Latex error converting to dvi. See log output above or the log file: C:\Animation Programs\Manim\manim_3_feb\manimlib\files\Texf78a457bde38f5.log
没有这样的 .log 文件,但是在完全相同的文件夹中有一个名称完全相同的 .tex 文件。 .tex 文件读取(在记事本中打开)
\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}
这个问题似乎在 the following post 中的一些人那里得到了解决,建议我 "change the commands = [...] in mobject/tex_mobject.py",但是在任何地方都没有 'command' 行tex_mobject.py 文件。
我复制了以下函数(显然应该已经存在于文件中,但没有)并将它们粘贴到 tex_mobject.py
def tex_to_dvi(tex_file):
result = tex_file.replace(".tex", ".dvi")
if not os.path.exists(result):
commands = [
"latex",
"-interaction=batchmode",
"-halt-on-error",
"-output-directory=" + TEX_DIR,
tex_file,
]
exit_code = os.system(" ".join(commands))
if exit_code != 0:
latex_output = ''
log_file = tex_file.replace(".tex", ".log")
if os.path.exists(log_file):
with open(log_file, 'r') as f:
latex_output = f.read()
if latex_output:
sys.stderr.write(latex_output)
raise Exception(
"Latex error converting to dvi. "
"See log output above or the log file: %s" % log_file)
return result
.
def dvi_to_svg(dvi_file, regen_if_exists = False):
"""
Converts a dvi, which potentially has multiple slides, into a
directory full of enumerated pngs corresponding with these slides.
Returns a list of PIL Image objects for these images sorted as they
where in the dvi
"""
result = dvi_file.replace(".dvi", ".svg")
if not os.path.exists(result):
commands = [
"dvisvgm",
dvi_file,
"-n",
"-v",
"0",
"-o",
result,
]
os.system(" ".join(commands))
return result
但我仍然遇到同样的错误。
在同一个 post 中,其他人建议查看引用的 .log 文件,因为这会让我知道是否缺少任何包。正如我所说,我没有这样的 .log 文件,相应的 .tex 文件似乎没有提到任何丢失的包。
非常感谢任何帮助!
该答案现在不再有用,因为 Manim 已经解决了该问题。所以这可能是由于两件事: 为了提示我们哪里出了问题,请使用终端转到 manimlib 文件夹,然后 运行 以下内容:
latex tex_template.tex
我们区分两种可能的错误:
识别到latex命令但是编译无法完成,因为你缺少库,要解决这个问题你可以安装终端指示缺少的包。
LaTeX 没有被识别为命令,在这种情况下肯定是 PATH 变量设置不正确,here is the solution.