How to set the QT_API enviornment variable


I’m trying to create a Qt application embedding Matplotlib, but the following error is occuring:

ImportError: Failed to import any of the following Qt binding modules: PyQt6, PySide6, PyQt5, PySide2

I checked at Matplotlib documentation and it says I have to set the enviornment variable QT_API, but I’m not sure how to do that. I’m using Windows and I already got to the Enviornment Variable window, but what path should I set there?

Or is there another way to bind de PyQt5 to matplotlib? I’m always confused when it comes to enviorment variables.

The environment variable will control which Qt binding we use, however the error your getting is than none of the Qt bindings we support are importable by your Python process.

Ok, thak you for the reply @tacaswell ! Is there any way to fix it?

You will need to install the Qt bindings using what ever mechanism you are using to manage your Python environment.