问题描述
ManimGL 运行出现 ValueError: operands could not be broadcast together with shapes (24,3) (0,3)
命令
manimgl start.py SquareToCircle
源码
from manimlib import *
class SquareToCircle(Scene):
def construct(self):
circle = Circle() # 创建一个圆
circle.set_fill(BLUE, opacity=0.5) # 设置圆的填充颜色和透明度
circle.set_stroke(BLUE_E, width=4) # 设置圆的边框颜色和宽度
self.add(circle) # 将圆添加到场景中
self.wait(1) # 等待1秒钟,以便可以观察动画
详细错误信息
PS F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t> manimgl start.py SquareToCircle
ManimGL v1.6.1
[13:26:44] INFO Using the default configuration file, which you can modify in `f:\360movedata\users\a\desktop\code\普通编程\python\动画\t\v\lib\site-packages\manimlib\default_config.yml` config.py:265 INFO If you want to create a local configuration file, you can create a file named `custom_config.yml`, or run `manimgl --config` config.py:266 WARNING You may be using Windows platform and have not specified the path of `temporary_storage`, which may cause OSError. So it is recommended to specify the `temporary_storage` in the config config.py:232 file (.yml)
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\__main__.py", line 25, in main
scene.run()
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\scene\scene.py", line 91, in run
self.construct()
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\start.py", line 5, in construct
circle = Circle() # 创建一个圆
^^^^^^^^
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\mobject\geometry.py", line 324, in __init__
Arc.__init__(self, 0, TAU, **kwargs)
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\mobject\geometry.py", line 218, in __init__
VMobject.__init__(self, **kwargs)
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\mobject\types\vectorized_mobject.py", line 85, in __init__
super().__init__(**kwargs)
self.init_points()
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\mobject\geometry.py", line 221, in init_points
self.set_points(Arc.create_quadratic_bezier_points(
File "F:\360MoveData\Users\A\Desktop\code\普通编程\python\动画\t\v\Lib\site-packages\manimlib\mobject\types\vectorized_mobject.py", line 968, in wrapper
if not np.all(self.get_points() == old_points):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: operands could not be broadcast together with shapes (24,3) (0,3)
解决办法
安装 1.24版本的numpy
pip install numpy==1.24
解决来源
https://github.com/3b1b/manim/issues/2114