jeertmans / manim-slides

Tool for live presentations using manim
https://manim-slides.eertmans.be
MIT License
446 stars 48 forks source link

[BUG] manim_slides giving qtpy.QtBindingsNotFoundError: No Qt bindings could be found error. #401

Closed NikoMolecule closed 6 months ago

NikoMolecule commented 6 months ago

Description

I wrote code and i tried to run and present manim into presentation but it popped up a really weird error.

i first called:

python -m manim_slides render  .\example_scenes.py rectangle

and after that

python -m manim_slides rectangle

This was error it thew up:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\manim_slides\__main__.py", line 73, in <module>
    cli()
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\manim_slides\present\__init__.py", line 288, in present
    config = Config()
             ^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\pydantic\main.py", line 171, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\pydantic\main.py", line 171, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\manim_slides\config.py", line 82, in <lambda>
    QUIT: Key = Field(default_factory=lambda: Key(ids=[key_id("Q")], name="QUIT"))
                                                       ^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\manim_slides\config.py", line 42, in key_id
    from qtpy.QtCore import Qt
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\qtpy\__init__.py", line 287, in <module>
    raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

and this is my code

from manim import *
from manim_slides import Slide
import numpy as np

class rectangle(Slide):
    def construct(self):
        box1 = Rectangle(stroke_color = RED_C, stroke_opacity = 0.7, fill_color = RED_B, fill_opacity=0.5, height = 1, width = 2).shift(3 * RIGHT)
        name1 = Tex("Discriminator D(z)", font_size = 18).move_to(box1.get_center())

        box2 = Rectangle(stroke_color = GREEN_C, stroke_opacity = 0.7, fill_color = GREEN_B, fill_opacity=0.5, height = 1, width = 2).shift(2.5 * DOWN + 3.75 * LEFT)
        name2 = Tex("Generator G(z)", font_size = 18).move_to(box2.get_center())

        box3 = Rectangle(stroke_color = GREY_A, stroke_opacity = 0.7, fill_color = BLACK, fill_opacity=0, height = 2, width = 2).shift(2.5 * UP + 1 * LEFT)
        name3 = Tex("Real Images", font_size = 18).move_to(box3.get_top())

        image1r = ImageMobject("../manim/logo/10.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * UP + 0.5 * LEFT)
        image2r = ImageMobject("../manim/logo/1012.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * UP + 0.5 * RIGHT)
        image3r = ImageMobject("../manim/logo/1022.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * DOWN + 0.5 * LEFT)
        image4r = ImageMobject("../manim/logo/1032.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * DOWN + 0.5 * RIGHT)

        box4 = Rectangle(stroke_color = GREY_A, stroke_opacity = 0.7, fill_color = BLACK, fill_opacity=0.5, height = 2, width = 1).shift(2.5 * DOWN + 5.6 * LEFT)
        name4 = Text("\n 0.000 \n -0.234 \n -3.456 \n 1.293 \n 0.015 \n ... \n -1.102 \n 0.998 \n -0.122", font_size = 18).move_to(box4.get_center())

        brace1 = Brace(box4, LEFT)
        name5 = Tex("100", font_size = 18).next_to(brace1, LEFT)
        name6 = Tex("Random Noise", font_size = 18).next_to(box4, 0.25 * UP)

        box7 = Rectangle(stroke_color = GREY_A, stroke_opacity = 0.7, fill_color = BLACK, fill_opacity=0, height = 2, width = 2).shift(2.5 * DOWN + 1 * LEFT)
        name7 = Tex("Fake Images", font_size = 18).move_to(box7.get_bottom())

        image1f = ImageMobject("../manim/logo/generated_plot_epoch-960.png").move_to(box7.get_center()).shift(0.5 * UP + 0.5 * LEFT)
        image2f = ImageMobject("../manim/logo/generated_plot_epoch-961.png").move_to(box7.get_center()).shift(0.5 * UP + 0.5 * RIGHT)
        image3f = ImageMobject("../manim/logo/generated_plot_epoch-962.png").move_to(box7.get_center()).shift(0.5 * DOWN + 0.5 * LEFT)
        image4f = ImageMobject("../manim/logo/generated_plot_epoch-963.png").move_to(box7.get_center()).shift(0.5 * DOWN + 0.5 * RIGHT)

        arrow_1 = Arrow(start = box3.get_right(), end = box1.get_left(), color = WHITE)
        arrow_2 = Arrow(start = box7.get_right(), end = box1.get_left(), color = WHITE)
        arrow_3 = Arrow(start = box2.get_right(), end = box7.get_left(), color = WHITE)
        arrow_4 = Arrow(start = box4.get_right(), end = box2.get_left(), color = WHITE)

        self.play(Create(box4), Create(name4), Create(brace1), Create(name5), Create(name6))
        self.next_slide()

        self.play(Create(arrow_4), Create(box2), Create(name2))
        self.next_slide()

        self.play(Create(arrow_3), Create(box7), Create(name7), FadeIn(image1f), FadeIn(image2f),FadeIn(image3f), FadeIn(image4f))
        self.play(Create(box3), Create(name3), FadeIn(image1r), FadeIn(image2r), FadeIn(image3r), FadeIn(image4r))
        self.next_slide()

        self.play(Create(arrow_1), Create(arrow_2), Create(box1), Create(name1))
        self.wait()

Version

5.1.3

Platform

Windows

Screenshots

No response

Additional information

No response

jeertmans commented 6 months ago

This is because you need Qt bindings, and you can install them using extras. Read more about this here: https://manim-slides.eertmans.be/latest/installation.html#when-you-need-a-qt-backend.

I hope it helps!

NikoMolecule commented 6 months ago

@jeertmans Well i installed Qt bindings but new problem arose. manim slides application was successfully runned but it only contained 4 black screens and nothing more. can you help me out?

[04/05/24 22:18:52] WARNING  You are using API = 'pyqt6', QT_VERSION = '6.6.1', but we recommend installing 'PySide6==6.5.2', mainly to avoid flashing        __init__.py:23
                             screens between slides, see issue https://github.com/jeertmans/manim-slides/issues/293. You can do so with `pip install
                             'manim-slides[pyside6]'`.
qt.qpa.window: QtWindows::DpiAwareness::PerMonitorVersion2 is not supported by current system.
QWindowsVistaStylePrivate: Load OpenThemeDataForDpi in uxtheme.dll failed
No QtMultimedia backends found. Only QMediaDevices, QAudioDevice, QSoundEffect, QAudioSink, and QAudioSource are available.
Failed to create QVideoSink "Not available"
Failed to initialize QMediaPlayer "Not available"
Failed to create QVideoSink "Not available"
Failed to create QVideoSink "Not available"
Failed to initialize QMediaPlayer "Not available"

this was the cmd output until the manim-slides started running

jeertmans commented 6 months ago

Hello, can you try to install PySide6 instead? As you can see, there is a warning that is here for a reason :)

However, this does not explain your issue in #402…

NikoMolecule commented 6 months ago

@jeertmans already tried installing pySide6, this didnt solved the problem!

jeertmans commented 6 months ago

@jeertmans already tried installing pySide6, this didnt solved the problem!

You need to uninstall PyQt6 so PySide6 is actually used :)

NikoMolecule commented 6 months ago

@jeertmans @jeertmans
image It didnt solved the problem i ran this two commands

pip uninstall pyqt6

and

pip install pyqt6

even tho i have pyside6=6.5.2 version it still gives same error

jeertmans commented 6 months ago

But do you still get that warning?

[04/05/24 22:18:52] WARNING  You are using API = 'pyqt6', QT_VERSION = '6.6.1', but we recommend installing 'PySide6==6.5.2', mainly to avoid flashing        __init__.py:23
                             screens between slides, see issue https://github.com/jeertmans/manim-slides/issues/293. You can do so with `pip install
                             'manim-slides[pyside6]'`.
NikoMolecule commented 6 months ago

@jeertmans yes

jeertmans commented 6 months ago

This means you either (1) did not uninstall PyQT6 correctly or (2) manim-slides is installed on a separate Python environment. This is probably because pip command is not using the same Python as python. You can solve that by using python -m pip ... instead.

You can also change the QT API for the current session with:

set QT_API=pyside6
python -m manim_slides rectangle

But you will need to do that every time you restart your shell.

NikoMolecule commented 6 months ago

@jeertmans when running

set QT_API=pyside6
python -m manim_slides rectangle

it gave me the same error with same warning

jeertmans commented 6 months ago

@jeertmans when running

set QT_API=pyside6
python -m manim_slides rectangle

it gave me the same error with same warning

Humm, I guess this is because you did not (un)install PyQT6 and PySide6 correctly.

Can you run:

python -m pip uninstall pyqt6
python -m pip install -U "manim-slides[pyside6-full]"
python -m manim_slides render  .\example_scenes.py rectangle
python -m manim_slides rectangle

And put the output here?

NikoMolecule commented 6 months ago

@jeertmans alr so it outputed this:

qt.qpa.window: SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) failed: COM error 0x57: The parameter is incorrect.
Qt's default DPI awareness context is DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2. If you know what you are doing you can overwrite this default using qt.co
nf (https://doc.qt.io/qt-6/highdpi.html#configuring-windows)
QWindowsVistaStylePrivate: Load OpenThemeDataForDpi in uxtheme.dll failed
    failed to get textures for frame; format: 172 textureConverter null
Device loss detected in Present()
Failed to create srv: COM error 0x887a0005: The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action.
Failed to initialize QRhiTexture wrapper for native texture object 2337814336080

and after that it rendered part of animation and went non responding

jeertmans commented 6 months ago

See #315 (and https://github.com/jeertmans/manim-slides/issues/402#issuecomment-2042776337).