Install these packages, I have same error when running matplotlib that installed using pip
pkgs.xorg.libxcb pkgs.xorg.xcbutilwm pkgs.xorg.xcbutilimage pkgs.xorg.xcbutilkeysyms pkgs.xorg.xcbutilrenderutil pkgs.xcb-util-cursor