I have recently moved over to NixOS and I am having an issue with a python project I am starting.
I have decided to move forward using Conda to handle my python environment based on the NixOS wiki. I am running NixOS with Sway (wayland) as my window manager. When I try to generate a figure with this code:
import matplotlib.pyplot as plt
fig = plt.figure()
I get the following error:
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
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, minimal, minimalegl, offscreen, vnc, webgl, xcb.
Aborted (core dumped)
I have searched around on the web, and have found several similar questions, but I’m too naive to understand where I am going wrong. For example, the same problem is referenced HERE, but I’m not savvy enough to follow the discussion. This issue is also discussed on the NixOS Discourse page.
I don’t remember from which forum I found this advice, but adjusting the script like this:
import matplotlib.pyplot as plt
import os
os.environ['QT_QPA_PLATFORM'] = "wayland"
fig = plt.figure()
Resolves at least the “xcb” error. So I am left with:
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, minimal, minimalegl, offscreen, vnc, webgl, xcb.
Aborted (core dumped)
I don’t know if I’m missing a package/library, if it’s an issue with my conda
environment, if it’s a NixOS issue? Thank you for helping me navigate my naivete. Cheers!