Python Could not load the Qt platform plugin "xcb" (even with wrapQtAppsHook)

Hello nix community,

I’m currently expericing an issue, where I’m unable to run a python app with opencv-python to capture a picture on a webcam.

Initially I was experiencing a different kind of issue with this message:

Original error was: cannot open shared object file: No such file or directory

So to address this issue I decided to create a shell, add and use FHS:

{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSUserEnv {
  name = "pipzone";
  targetPkgs = pkgs: (with pkgs; [
  runScript = "zsh";

and then I got stuck up to this point.
I’m aware of the wrapper wrapQtAppsHook, I have already tried to use it in several different settings:

  • by adding libsForQt5.qt5.wrapQtAppsHook package to the targetPkgs list in buildFHSUserEnv
  • by adding *wrapQtAppsHook** to nativeBuildInputs
  • by creating derivation.nix file from Projects using python (e.g. PyQt5) and importing it to my shell

I just can’t make it work!
I have also tried following the several threads for the same type of issue, but unfortunatelly none of them have worked for me.

Any help will be much appriciated!

Have you found any solution to this?
I am trying to use buildFHSUserEnv with a qt app as well and its throwing out the same error.

Hey @insertokname

No, unfortunatelly I haven’t resolved this issue.
The obvious part for me is that the culprit of the issue in my case is with cv2.imshow("Image", frame).
If you are also using opencv along with that method, you can just remove it and the issue won’t occur anymore.

There is a discussion in Github about how to"fix" the issue - however when I try to follow the solution by installing opencv-python I encountered an installation error, so I had to install
But still it didn’t solve the issue.

If you are really dedicated you can follow this thread and re-create your environment according to the community reccomendations.

Sorry, I don’t have anything to share :frowning: