Manim的问题. “将错误转换为dvi." [英] Issues with Manim. 'error converting to dvi.'

查看:463
本文介绍了Manim的问题. “将错误转换为dvi."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Manim(Youtuber 3Blue1Brown python的库)进行动画处理.我已经安装了必要的软件,包括最新版本的MikTex和python.我可以运行SquareToCircle动画,但是每当我尝试运行任何涉及文本的动画时,都会出现以下错误:

I'm attempting to use Manim (Youtuber 3Blue1Brown python's library) to animate. I have installed the necessary software including the newest versions of MikTex and python. I'm able to run the SquareToCircle animation, but whenever I try to run any animation involving text I get the following error:

Exception: Latex error converting to dvi. See log output above or the log file: C:\Animation Programs\Manim\manim_3_feb\manimlib\files\Tex\47f78a457bde38f5.log

没有这样的.log文件,但是在完全相同的文件夹中有一个完全相同名称的.tex文件. .tex文件读取(在NotePad中打开)

There is no such .log file, however there is a .tex file in the exact same folder with the exact same name. The .tex file reads (opening in NotePad)

\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}


该问题似乎已经在以下帖子中的某些问题中得到解决.建议我在mobject/tex_mobject.py中更改命令= [...]",但tex_mobject.py文件中的任何地方都没有命令行".


The issue seemed to be solved for some in the following post, where it is advised that I "change the commands = [...] in mobject/tex_mobject.py", yet there is no 'command' line anywhere in the tex_mobject.py file.

我复制了以下函数(显然应该已经存在于文件中,但实际上不存在)并将它们粘贴到tex_mobject.py

I copied the following functions (which apparently should already exist in the file, but didn't) and pasted them in 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

但是我仍然遇到相同的错误.

Yet I'm still getting the same error.

在同一篇文章中,其他人建议您看看引用的.log文件,因为这会让我知道是否缺少任何软件包.如我所说,我没有这样的.log文件,并且相应的.tex文件似乎没有提及任何丢失的软件包.

In the same post others advise to take a look at the referenced .log file, since this will let me know if any packages are missing. As I said, I have no such .log file, and the corresponding .tex file seems to make no mention of any missing packages.

我将非常感谢您的帮助!

I would really appreciate any help!

推荐答案

该答案现在不再有用,因为Manim已经解决了该问题.因此,这可能是由于两件事: 为了告诉我们什么地方不对,请使用终端转到manimlib文件夹,然后运行以下命令:

That answer is no longer useful now because Manim has already solved that problem. So this may be due to two things: To give us a hint of what is wrong, go to the manimlib folder with the terminal and run the following:

latex tex_template.tex

我们区分两个可能的错误:

We distinguish the two possible errors:

  1. 已识别出Latex命令,但由于缺少库而无法完成编译,要解决此问题,您可以安装终端指示的缺少的软件包.

  1. Recognized the latex command but the compilation could not be completed because you are missing libraries, to solve this you can install the missing packages indicated by the terminal.

不能将LaTeX识别为命令,在这种情况下,肯定会正确设置PATH变量,

That LaTeX is not recognized as a command, in this case surely the PATH variable is not set correctly, here is the solution.

这篇关于Manim的问题. “将错误转换为dvi."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆