Qt platform plugin "wayland" not found while running Python in VScode on Ubuntu

1.6k views Asked by At


I ran into the following problem, which prevents me from plotting figures in VScode.
As a minimal example, I am trying to run the following Python script in VScode:

from matplotlib import pyplot as plt
plt.plot([1,2,3], [5,4,3])

This outputs qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "".

Python 3.9.15
Anaconda Navigator 2.3.2
conda 22.11.1
matplotlib 3.6.2
Visual Studio Code 1.74.2
OS Name: Ubuntu 22.04.1 LTS
GNOME Version: 42.5
Windowing System: Wayland

So far, I have tried:

  1. Installing qtwayland5 by running sudo apt-get install -y qtwayland5. This is already installed in the newest version (5.15.3-1).
  2. I have tried the following to find where it is installed.

which qtwayland5 -> empty output
whereis qtwayland5 -> qtwayland5:
locate qtwayland5 ->

/usr/share/doc/qtwayland5
/usr/share/doc/qtwayland5/changelog.Debian.gz
/usr/share/doc/qtwayland5/copyright
/var/cache/apt/archives/qtwayland5_5.15.3-1_amd64.deb
/var/lib/dpkg/info/qtwayland5:amd64.list
/var/lib/dpkg/info/qtwayland5:amd64.md5sums

Both locate wayland and locate qt give hundreds of results in various locations.

My plan was to add the directory containing qtwayland5 to the $PATH variable, but now I don't know, which of the many directories is the right one (if this would even solve the problem).

Thank you for taking the time to read through my question. Any help would be greatly appreciated as I have spent a lot of time looking for a solution.

1

There are 1 answers

1
OcraCore On

Installing matplotlib via pip install matplotlib instead of conda install matplotlib resolved the issue for me.