0

Manim で Hello World プログラムを作成しようとしています。

Manim とその前提プログラムをインストールし、コマンド プロンプトからサンプル コードを意図したとおりに実行できます。このサンプル コードは通常とは異なる動作をします。ユーザーが .py ファイルだけでなく、その中の 1 つのクラスも指定してコマンドを発行すると、Python がクラス定義コードを実行しますが、クラスをインスタンス化していないように見えます。

現在、外部コマンドを必要とするのではなく、実行時にクラスをインスタンス化することで機能するスタンドアロンの .py ファイルを作成しようとしています (Visual Studio Community 2019 で実行しています)。

同様の質問の多くを確認しましたが、残念ながら、それらはすべて一般的な Hello World プログラムに関するものであり、多くの非 Python 言語にまたがっています。

私はいくつかの AttributeError: ' ____ ' object has no attribute '____' の質問を検索で見つけました。と明示的に書いています。

また、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)

これは、上記のコードによって生成されるエラー メッセージです。

Media will be stored in ./media\. You can change this behavior by writing a 
diff
erent directory to media_dir.txt.
Traceback (most recent call last):
  File "C:\Users\Admin\Documents\Visual Studio 
2019\Projects\PythonApplication1\
PythonApplication1\PythonApplication1.py", line 8, in <module>
    scene1 = Scene()
  File "C:\Users\Admin\PortableApps\manim-0.1.5\manimlib\scene\scene.py", 
line 3
7, in __init__
    self, **self.file_writer_config,
  File "C:\Users\Admin\PortableApps\manim- 
0.1.5\manimlib\scene\scene_file_writer
.py", line 44, in __init__
    self.init_output_directories()
  File "C:\Users\Admin\PortableApps\manim- 
0.1.5\manimlib\scene\scene_file_writer
.py", line 49, in init_output_directories
    output_directory = self.output_directory or 
self.get_default_output_director
y()
  File "C:\Users\Admin\PortableApps\manim- 
0.1.5\manimlib\scene\scene_file_writer
.py", line 80, in get_default_output_directory
    filename = os.path.basename(self.input_file_path)
AttributeError: 'SceneFileWriter' object has no attribute 'input_file_path'
Press any key to continue . . .

プログラムの出力は、「Hello World!」というテキストの表示になると思います。しかし、実際の出力は AttributeError: 'SceneFileWriter' object has no attribute 'input_file_path' で、上記のメッセージの残りの部分が伴います。

4

2 に答える 2