Stars-Knowledge 2024-07-24 20:47 采纳率: 0%
浏览 86

为什么运行manim时出现这样的报错?

错误内容:
ValueError: Your installation does not support converting .dvi files to SVG. Consider updating dvisvgm to atleast version 2.4.
但我的dvisvgm版本已经为3.3,ffmpeg也已经安装。
完整信息如下:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\cli\render\commands.py:1 │        
│ 20 in render                                                                                     │        
│                                                                                                  │        
│   117 │   │   │   try:                                                                           │        
│   118 │   │   │   │   with tempconfig({}):                                                       │        
│   119 │   │   │   │   │   scene = SceneClass()                                                   │        
│ ❱ 120 │   │   │   │   │   scene.render()                                                         │        
│   121 │   │   │   except Exception:                                                              │        
│   122 │   │   │   │   error_console.print_exception()                                            │        
│   123 │   │   │   │   sys.exit(1)                                                                │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\scene\scene.py:229 in    │        
│ render                                                                                           │        
│                                                                                                  │        
│    226 │   │   """                                                                               │        
│    227 │   │   self.setup()                                                                      │        
│    228 │   │   try:                                                                              │        
│ ❱  229 │   │   │   self.construct()                                                              │        
│    230 │   │   except EndSceneEarlyException:                                                    │        
│    231 │   │   │   pass                                                                          │        
│    232 │   │   except RerunSceneException as e:                                                  │        
│                                                                                                  │        
│ C:\Users\Remilia Scarlet\Desktop\Manim动画\自制\hellp.py:8 in construct                          │        
│                                                                                                  │        
│    5 │   │   dot2 = Dot([2, 1, 0])                                                               │        
│    6 │   │   line = Line(dot.get_center(), dot2.get_center()).set_color(ORANGE)                  │        
│    7 │   │   b1 = Brace(line)                                                                    │        
│ ❱  8 │   │   b1text = b1.get_text("Horizontal distance")                                         │        
│    9 │   │   b2 = Brace(line, direction=line.copy().rotate(PI / 2).get_unit_vector())            │        
│   10 │   │   b2text = b2.get_tex("x-x_1")                                                        │        
│   11 │   │   self.add(line, dot, dot2, b1, b2, b1text, b2text)                                   │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\mobject\svg\brace.py:139 │        
│ in get_text                                                                                      │        
│                                                                                                  │        
│   136 │   │   return self                                                                        │        
│   137 │                                                                                          │        
│   138 │   def get_text(self, *text, **kwargs):                                                   │        
│ ❱ 139 │   │   text_mob = Tex(*text)                                                              │        
│   140 │   │   self.put_at_tip(text_mob, **kwargs)                                                │        
│   141 │   │   return text_mob                                                                    │        
│   142                                                                                            │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\mobject\text\tex_mobject │        
│ .py:443 in __init__                                                                              │        
│                                                                                                  │        
│   440 │   def __init__(                                                                          │        
│   441 │   │   self, *tex_strings, arg_separator="", tex_environment="center", **kwargs           │        
│   442 │   ):                                                                                     │        
│ ❱ 443 │   │   super().__init__(                                                                  │        
│   444 │   │   │   *tex_strings,                                                                  │        
│   445 │   │   │   arg_separator=arg_separator,                                                   │        
│   446 │   │   │   tex_environment=tex_environment,                                               │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\mobject\text\tex_mobject │        
│ .py:293 in __init__                                                                              │        
│                                                                                                  │        
│   290 │   │   │   │   │   │   """,                                                               │        
│   291 │   │   │   │   │   ),                                                                     │        
│   292 │   │   │   │   )                                                                          │        
│ ❱ 293 │   │   │   raise compilation_error                                                        │        
│   294 │   │   self.set_color_by_tex_to_color_map(self.tex_to_color_map)                          │        
│   295 │   │                                                                                      │        
│   296 │   │   if self.organize_left_to_right:                                                    │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\mobject\text\tex_mobject │        
│ .py:272 in __init__                                                                              │        
│                                                                                                  │        
│   269 │   │   self.brace_notation_split_occurred = False                                         │        
│   270 │   │   self.tex_strings = self._break_up_tex_strings(tex_strings)                         │        
│   271 │   │   try:                                                                               │        
│ ❱ 272 │   │   │   super().__init__(                                                              │        
│   273 │   │   │   │   self.arg_separator.join(self.tex_strings),                                 │        
│   274 │   │   │   │   tex_environment=self.tex_environment,                                      │        
│   275 │   │   │   │   tex_template=self.tex_template,                                            │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\mobject\text\tex_mobject │        
│ .py:81 in __init__                                                                               │        
│                                                                                                  │        
│    78 │   │                                                                                      │        
│    79 │   │   assert isinstance(tex_string, str)                                                 │        
│    80 │   │   self.tex_string = tex_string                                                       │        
│ ❱  81 │   │   file_name = tex_to_svg_file(                                                       │        
│    82 │   │   │   self._get_modified_expression(tex_string),                                     │        
│    83 │   │   │   environment=self.tex_environment,                                              │        
│    84 │   │   │   tex_template=self.tex_template,                                                │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ Scarlet\AppData\Local\Programs\Python\Python312\Lib\site-packages\manim\utils\tex_file_writing.p │        
│ y:68 in tex_to_svg_file                                                                          │        
│                                                                                                  │        
│    65 │   │   tex_template.tex_compiler,                                                         │        
│    66 │   │   tex_template.output_format,                                                        │        
│    67 │   )                                                                                      │        
│ ❱  68 │   svg_file = convert_to_svg(dvi_file, tex_template.output_format)                        │        
│    69 │   if not config["no_latex_cleanup"]:                                                     │        
│    70 │   │   delete_nonsvg_files()                                                              │        
│    71 │   return svg_file                                                                        │        
│                                                                                                  │        
│ C:\Users\Remilia                                                                                 │        
│ y:255 in convert_to_svg                                                                          │
│                                                                                                  │
│   252 │                                                                                          │
│   253 # if the file does not exist now, this means conversion failed                         │ 254 │   if not result.exists():                                                                │
│ ❱ 255 │   │   raise ValueError(                                                                  │
│   256 │   │   │   f"Your installation does not support converting {dvi_file.suffix} files to S   │
│   257 │   │   │   f" Consider updating dvisvgm to at least version 2.4."                         │
│   258 │   │   │   f" If this does not solve the problem, please refer to our troubleshooting g   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

ValueError: Your installation does not support converting .dvi files to SVG. Consider updating dvisvgm to atleast version 2.4. If this does not solve the problem, please refer to our troubleshooting guide at:
https://docs.manim.community/en/stable/faq/general.html#my-installation-does-not-support-converting-pdf-to-svg-help

  • 写回答

4条回答 默认 最新

  • 阿里嘎多学长 2024-07-24 20:48
    关注

    以下内容由AIGC及阿里嘎多学长共同生成、有用望采纳:


    您好!根据您提供的错误信息和代码,这个问题可能是由于Manim在尝试将LaTeX生成的.dvi文件转换为SVG格式时遇到了问题。尽管您已经安装了dvisvgm的3.3版本,但Manim可能没有正确地调用或识别它。以下是一些可能的解决方案和分析步骤:

    解决方案

    1. 确认dvisvgm安装

      • 打开命令行工具,运行dvisvgm --version来确认dvisvgm的版本。
    2. 检查环境变量

      • 确保dvisvgm的可执行文件路径已经添加到系统的环境变量中。
    3. 检查LaTeX环境

      • 确保LaTeX环境配置正确,所有必要的包都已经安装。
    4. 检查Python脚本

      • 确保您的Python脚本和Manim库是最新版本。
    5. 尝试重新安装Manim

      • 有时候重新安装Manim可以解决一些不兼容的问题。
    6. 查看Manim文档和社区

      • 访问Manim文档和社区,看看是否有其他人遇到了类似的问题。

    示例代码修改

    您的代码中使用get_text方法可能会遇到问题,因为它依赖于LaTeX的.dvi到SVG的转换。您可以尝试使用get_tex方法,它可能对Manim的兼容性更好。以下是修改后的示例代码:

    from manim import *
    
    class HelloWorld(Scene):
        def construct(self):
            dot = Dot([2, 1, 0])
            line = Line(dot.get_center(), [2, 1, 0]).set_color(ORANGE)
            b1 = Brace(line)
            b1text = b1.get_tex("Horizontal distance")  # 使用get_tex代替get_text
            
            b2 = Brace(line, direction=line.copy().rotate(PI / 2).get_unit_vector())
            b2text = b2.get_tex("x-x_1")  # 使用get_tex代替get_text
            
            self.add(line, dot, b1, b2, b1text, b2text)
    

    示例输入和输出

    • 示例输入:LaTeX字符串,例如"Horizontal distance""x-x_1"
    • 示例输出:期望在屏幕上看到一条线,两端有括号,括号内包含LaTeX文本。

    附加说明

    如果上述步骤仍然无法解决问题,您可能需要更详细地检查您的系统配置,或者考虑在Manim社区中寻求帮助。此外,您提供的链接指向了Manim的故障排除指南,这可能是解决此问题的一个有用资源。

    希望这些信息对您有所帮助!如果还有其他问题或需要进一步的帮助,请随时告诉我。

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 7月24日