Could not find the Qt platform plugin "wayland"

I was trying to use the Matplotlib module from Python, but every time i try to execute a function that should open a new window, it works, but returns qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "" in the terminal.

I think that it doesn’t like the fact that i use wayland, but do you have any idea about how to solve that ?

A script that displays the error :

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0, 1)
plt.plot(x, x*x)
plt.show()

The output of inxi --admin --verbosity=7 --filter --width:

System:
  Kernel: 5.15.32-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 11.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-5.15-x86_64
    root=UUID=64c7e4aa-2dae-4fbe-83d2-3f806bd40ac8 rw quiet
    udev.log_priority=3
  Desktop: KDE Plasma v: 5.24.4 tk: Qt v: 5.15.3 wm: kwin_wayland vt: 2
    dm: SDDM Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 82LN v: IdeaPad 5 15ALC05
    serial: <superuser required> Chassis: type: 10 v: IdeaPad 5 15ALC05
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0J40709WIN
    serial: <superuser required> UEFI: LENOVO v: H2CN23WW date: 12/13/2021
Battery:
  ID-1: BAT0 charge: 57.7 Wh (92.2%) condition: 62.6/70.0 Wh (89.4%)
    volts: 16.8 min: 15.2 model: Celxpert L19C4PF1 type: Li-poly
    serial: <filter> status: discharging cycles: 85
Memory:
  RAM: total: 5.72 GiB used: 5.34 GiB (93.4%)
  RAM Report:
    permissions: Unable to run dmidecode. Root privileges required.
CPU:
  Info: model: AMD Ryzen 7 5700U with Radeon Graphics bits: 64 type: MT MCP
    arch: Zen 2 family: 0x17 (23) model-id: 0x68 (104) stepping: 1
    microcode: 0x8608102
  Topology: cpus: 1x cores: 8 tpc: 2 threads: 16 smt: enabled cache:
    L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 4 MiB desc: 8x512 KiB L3: 8 MiB
    desc: 2x4 MiB
  Speed (MHz): avg: 1656 high: 2525 min/max: 1400/4370 boost: enabled
    scaling: driver: acpi-cpufreq governor: schedutil cores: 1: 2525 2: 1616
    3: 1638 4: 1698 5: 1397 6: 1595 7: 1807 8: 1445 9: 1784 10: 1408 11: 1397
    12: 1398 13: 1399 14: 1696 15: 1826 16: 1881 bogomips: 57505
  Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1
    bmi2 bpext cat_l3 cdp_l3 clflush clflushopt clwb clzero cmov cmp_legacy
    constant_tsc cpb cpuid cqm cqm_llc cqm_mbm_local cqm_mbm_total
    cqm_occup_llc cr8_legacy cx16 cx8 de decodeassists extapic extd_apicid
    f16c flushbyasid fma fpu fsgsbase fxsr fxsr_opt ht hw_pstate ibpb ibrs ibs
    irperf lahf_lm lbrv lm mba mca mce misalignsse mmx mmxext monitor movbe
    msr mtrr mwaitx nonstop_tsc nopl npt nrip_save nx osvw overflow_recov pae
    pat pausefilter pclmulqdq pdpe1gb perfctr_core perfctr_llc perfctr_nb
    pfthreshold pge pni popcnt pse pse36 rapl rdpid rdpru rdrand rdseed rdt_a
    rdtscp rep_good sep sha_ni skinit smap smca smep ssbd sse sse2 sse4_1
    sse4_2 sse4a ssse3 stibp succor svm svm_lock syscall tce topoext tsc
    tsc_scale umip v_spec_ctrl v_vmsave_vmload vgif vmcb_clean vme vmmcall
    wbnoinvd wdt xgetbv1 xsave xsavec xsaveerptr xsaveopt xsaves
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: spec_store_bypass
    mitigation: Speculative Store Bypass disabled via prctl and seccomp
  Type: spectre_v1
    mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: conditional, RSB filling
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Lucienne vendor: Lenovo driver: amdgpu v: kernel pcie: gen: 3
    speed: 8 GT/s lanes: 16 link-max: gen: 4 speed: 16 GT/s ports: active: eDP-1
    empty: DP-1,HDMI-A-1 bus-ID: 03:00.0 chip-ID: 1002:164c class-ID: 0300
  Device-2: Syntek Integrated Camera type: USB driver: uvcvideo
    bus-ID: 1-3:2 chip-ID: 174f:2459 class-ID: fe01 serial: <filter>
  Display: wayland server: X.org v: 1.21.1.3 with: Xwayland v: 22.1.1
    compositors: 1: kwin_wayland 2: kwin_x11 driver: X: loaded: amdgpu
    unloaded: modesetting,radeon alternate: fbdev,vesa gpu: amdgpu
    display-ID: 0
  Monitor-1: eDP-1 res: 1920x1080 size: N/A modes: N/A
  OpenGL: renderer: AMD RENOIR (DRM 3.42.0 5.15.32-1-MANJARO LLVM 13.0.1)
    v: 4.6 Mesa 21.3.8 direct render: Yes
Audio:
  Device-1: AMD Renoir Radeon High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
    link-max: gen: 4 speed: 16 GT/s bus-ID: 03:00.1 chip-ID: 1002:1637
    class-ID: 0403
  Device-2: AMD ACP/ACP3X/ACP6x Audio Coprocessor vendor: Lenovo driver: N/A
    alternate: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x pcie: gen: 3
    speed: 8 GT/s lanes: 16 link-max: gen: 4 speed: 16 GT/s bus-ID: 03:00.5
    chip-ID: 1022:15e2 class-ID: 0480
  Device-3: AMD Family 17h/19h HD Audio vendor: Lenovo driver: snd_hda_intel
    v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16 link-max: gen: 4
    speed: 16 GT/s bus-ID: 03:00.6 chip-ID: 1022:15e3 class-ID: 0403
  Sound Server-1: ALSA v: k5.15.32-1-MANJARO running: yes
  Sound Server-2: JACK v: 1.9.20 running: no
  Sound Server-3: PulseAudio v: 15.0 running: yes
  Sound Server-4: PipeWire v: 0.3.49 running: yes
Network:
  Device-1: Realtek RTL8822CE 802.11ac PCIe Wireless Network Adapter
    vendor: Lenovo driver: rtw_8822ce v: N/A modules: rtw88_8822ce pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 port: 2000 bus-ID: 01:00.0 chip-ID: 10ec:c822
    class-ID: 0280
  IF: wlp1s0 state: up mac: <filter>
  IP v4: <filter> type: dynamic noprefixroute scope: global
    broadcast: <filter>
  IP v6: <filter> type: noprefixroute scope: link
  WAN IP: <filter>
Bluetooth:
  Device-1: Realtek Bluetooth Radio type: USB driver: btusb v: 0.8
    bus-ID: 3-3:2 chip-ID: 0bda:c123 class-ID: e001 serial: <filter>
  Report: rfkill ID: hci0 rfk-id: 8 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: see --recommends
Logical:
  Message: No logical block device data found.
RAID:
  Message: No RAID data found.
Drives:
  Local Storage: total: 476.94 GiB used: 189.73 GiB (39.8%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Lenovo
    model: UMIS RPJTJ512MEE1OWX size: 476.94 GiB block-size: physical: 512 B
    logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
    rev: 2.1C0628 temp: 34.9 C scheme: GPT
  Message: No optical or floppy data found.
Partition:
  ID-1: / raw-size: 237.85 GiB size: 233.05 GiB (97.99%)
    used: 45.75 GiB (19.6%) fs: ext4 dev: /dev/nvme0n1p5 maj-min: 259:5
    label: N/A uuid: 64c7e4aa-2dae-4fbe-83d2-3f806bd40ac8
  ID-2: /boot/efi raw-size: 260 MiB size: 256 MiB (98.46%)
    used: 28.6 MiB (11.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
    label: SYSTEM_DRV uuid: 4ED7-C9AA
  ID-3: /run/media/nora/Windows-SSD raw-size: 237.85 GiB
    size: 237.85 GiB (100.00%) used: 143.96 GiB (60.5%) fs: ntfs
    dev: /dev/nvme0n1p3 maj-min: 259:3 label: Windows-SSD
    uuid: 466CDAAD6CDA9751
Swap:
  Alert: No swap data was found.
Unmounted:
  ID-1: /dev/nvme0n1p2 maj-min: 259:2 size: 16 MiB fs: <superuser required>
    label: N/A uuid: N/A
  ID-2: /dev/nvme0n1p4 maj-min: 259:4 size: 1000 MiB fs: ntfs
    label: WINRE_DRV uuid: 5802DBE802DBC960
USB:
  Hub-1: 1-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0
    speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
  Device-1: 1-3:2 info: Syntek Integrated Camera type: Video
    driver: uvcvideo interfaces: 3 rev: 2.0 speed: 480 Mb/s power: 500mA
    chip-ID: 174f:2459 class-ID: fe01 serial: <filter>
  Hub-2: 2-0:1 info: Super-speed hub ports: 2 rev: 3.1 speed: 10 Gb/s
    chip-ID: 1d6b:0003 class-ID: 0900
  Hub-3: 3-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0
    speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
  Device-1: 3-3:2 info: Realtek Bluetooth Radio type: Bluetooth
    driver: btusb interfaces: 2 rev: 1.0 speed: 12 Mb/s power: 500mA
    chip-ID: 0bda:c123 class-ID: e001 serial: <filter>
  Hub-4: 4-0:1 info: Super-speed hub ports: 2 rev: 3.1 speed: 10 Gb/s
    chip-ID: 1d6b:0003 class-ID: 0900
Sensors:
  System Temperatures: cpu: N/A mobo: N/A gpu: amdgpu temp: 50.0 C
  Fan Speeds (RPM): N/A
Info:
  Processes: 381 Uptime: 1d 3h 17m wakeups: 6 Init: systemd v: 250
  tool: systemctl Compilers: gcc: 11.2.0 clang: 13.0.1 Packages: pacman: 1203
  lib: 341 Shell: Zsh v: 5.8.1 default: Bash v: 5.1.16 running-in: konsole
  inxi: 3.3.15

According to ArchWiki, to run any Qt application in wayland you need to install qt5-wayland and use the QT_QPA_PLATFORM=wayland environment variable.

well, i think that nothing appeared because of me who forgot to call plt.show(), but since i still had the message (even if the window opened afterwards), i tried installing qt5-wayland and setting the environment variable using export, but this time the window doesn’t open, and i get an error saying that no Qt platform plugin could be initialized
The error :

Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot()
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, xcb.

zsh: IOT instruction (core dumped)  python

I have the same issue. Latest Manjaro with KDE. Python 3.9.13. I installed both qt5-wayland and qt6-wayland. Any solution please?

In [1]: import matplotlib.pyplot as plt

In [2]: plt.plot([1,2,3,4,5])
qt.qpa.plugin: Could not find the Qt platform plugin “wayland” in “”

Operating System: Manjaro Linux
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 6.0.2-2-MANJARO (64-bit)
Graphics Platform: Wayland
Processors: 12 × Intel® Core™ i7-8700K CPU @ 3.70GHz
Memory: 62.7 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630

That’s quite old, your system doesn’t seem to be up to date.