我正试图用Manim编写一个Hello World程序。在
我已经安装了Manim及其必备程序,并且可以根据需要从命令提示符运行示例代码。这个示例代码以一种不寻常的方式运行;用户发出一个命令,不仅指定一个.py文件,而且指定其中的一个类,Python执行类定义代码,似乎没有实例化该类。在
现在我尝试编写一个独立的.py文件,它在运行时实例化一个类(我在VisualStudioCommunity2019中运行它),而不是需要外部命令。在
我已经检查了许多类似的问题,但不幸的是,它们都是关于helloworld程序的,甚至跨越了许多非Python语言。在
我发现了一些AttributeError:'\\'object has no attribute'\\'问题在搜索中,包括这个有用的解释(https://stackoverflow.com/a/8696339/2364796),但似乎没有适用于我显式编写的代码。在
我还检查了IRC,有人建议问题是在导入的代码中触发的。但是,当导入到示例中时,相同的代码可以正常工作,因此我必须不正确地处理它。在
这是我的Hello World程序的当前代码。在
from manimlib.imports import *
class GreetingScript(Scene):
def construct(self):
characters = TextMobject("Hello World!")
self.add(characters)
scene1 = Scene()
readthrough = GreetingScript(scene1)
这是由上述代码产生的错误消息。在
^{pr2}$我希望程序的输出是文本“helloworld!”的显示但实际的输出是AttributeError:“SceneFileWriter”对象没有属性“input_file_path”以及上面的其余消息。在
你试过什么吗?在
解决这个问题的最好方法是删除创建
scene1
对象的代码。要使此代码工作,需要仅实现场景类的源代码,并且可以使用以下方法生成场景:-p
标志表示渲染场景后打开视频。我希望这能对你的问题有所帮助。在相关问题 更多 >
编程相关推荐