这个错误是由于Manim尝试读取默认的编码格式(GBK),而输入的文本是UTF-8编码所导致的。你可以通过在代码开头添加以下两行来解决这个问题:

import sys
sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')

这样就可以正确读取和输出中文文本了。完整的代码如下:

# -*- coding: utf-8 -*-
from manim import *
from manim import MathTex
import sys
sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')

class CircleToSquare(Scene):
    def construct(self):
        equation = MathTex(r"这是一个中文文本")
        self.play(Write(equation))
        self.wait()

if __name__ == "__main__":
    scene = CircleToSquare()
    scene.render()

希望对你有帮助

# -- coding utf-8 --from manim import from manim import MathTeximport syssysstdinreconfigureencoding=utf-8sysstdoutreconfigureencoding=utf-8class CircleToSquareScene def constructself equati

原文地址: http://www.cveoy.top/t/topic/iTyu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录