[Python] How to fix DpiAwarenessContext Qt error in the context of pytest on Windows 11?

Discussão em 'Python' iniciado por Stack, Agosto 19, 2025.

  1. Stack

    Stack Membro Participativo

    On Windows 11 I am trying to run pytest using Poetry and a very complex test setup, which uses Qt for some things. However, when running this complex test (which worked before, and seems to work for everyone else) I get an error:

    qt.qpa.window: SetProcessDpiAwarenessContext() failed: Access is denied.
    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.conf (https://doc.qt.io/qt-6/highdpi.html#configuring-windows).


    As the web page suggests I added the text

    [Platforms]
    WindowsArguments = dpiawareness=0,1,2


    to a newly created file qt.conf in the folder I am starting the test as

    poetry run pytest .\mytests\test1.py::test_performance


    However, that does not solve the issue. The error is still there and the test does not run. Is there a way to solve this problem?

    Continue reading...

Compartilhe esta Página