Running a QT application that has been installed by Anaconda

I could use some help here.

I’ve been trying to run CQ-editor, a viewer for CAD models created by CadQuery. CQ-editor and CadQuery are both installed through Anaconda.

My window manager is Sway on Wayland. Other QT applications (eg. OpenSCAD) run fine in my regular user environment. But when I try to run CQ-editor (through my Conda environment) I get the error:

This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

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

Reinstalling the application may fix this problem.
Aborted

That empty string at the end of the first line does look suspcious. I’ve been able to change it by setting the environment variable QT_QPA_PLATFORM_PLUGIN_PATH, but every path I’ve tried has produced the same error message. I’ve tried /home/marcus/.conda/plugins, /home/marcus/.nix-profile/lib/qt-5.12/plugins/platforms and a few others. They all have libqxcb.so in them (which I assume is what QT is looking for).

I’ll describe my setup here. I include some extra packages in my Conda environment using an overlay, conda = super.conda.override { extraPkgs = [ super.libGL super.libGLU super.xorg.libX11 super.qt5 super.libsForQt5 super.strace ]; };

Conda is installed using home-manager home.packages.

To get CQ-editor installed my process is:

rm -rf ~/.conda
nixos-rebuild switch
conda-shell-4.3.31
conda-install
conda install -c cadquery -c conda-forge cq-editor cadquery=2
QT_QPA_PLATFORM= cq-editor

I have confirmed the Conda shell is working properly for CadQuery; I can start a python3 interpreter, load the CadQuery module and render a basic box to a SVG. Which I find pretty impressive actually, kudos to whoever wrote that Conda environment, I was expecting hours of messing around in order to get an Anaconda package working under NixOS.

Has anyone got any advice where I should go from here to get CQ-editor working?

This may be able to help. I have had this issue before for a different application. But here is the nix wiki on qt5 Qt - NixOS Wiki. I believe that you need to set QT_PLUGIN_PATH = qt5.qtbase.bin + "/" + qt5.qtbase.qtPluginPrefix;

1 Like

Thanks. I’m a bit embarrassed I missed that section of the wiki and also the qt section of the nixpkgs manual.

Setting QT_PLUGIN_PATH didn’t work, but the nix wiki introduced me to QT_DEBUG_PLUGINS, which let me see that qt was getting it’s xcb library from ~/.conda/… This version of xcb needed libXi.so, so sticking xlibs.libXi into my overlay’s extraPkgs was enough to get it working.

For anybody else who runs into this, my final inputs to get CQ-editor working were: conda = super.conda.override { extraPkgs = [ super.libGL super.libGLU super.xorg.libX11 super.xlibs.libXi super.qt5.qtbase ]; };

Thanks for posting the solution! While this is on the topic of conda with nix. How has your experience with the two together? Are you using nixos? I’m interested since prior to using nix/nixos I was a heavy conda user.

Also I would be happy to help package cad query for nixpkgs is you are interested

I do use NixOS, I’ve been using it almost exclusively for 2 years now. Although I’m not as advanced as most Nix users, I’m not a professional programmer, I’m actually a mechanical engineer but my job is flexible enough to let me use NixOS. I never used Conda before, even though I have done a lot in Python.

My experience with the two so far has been surprisingly smooth. But I guess that’s because Anaconda doesn’t leave much up to the OS. All I have installed through Conda is cq-editor and CadQuery, yet it’s still downloaded about 160 packages, including qt-5.

Thanks for the offer of help, I would certainly need it. I am thinking about packaging it properly, but I’ll test it out for a while first and if I stick with it I’ll package it then.

Great to hear. I have to do a lot of conda packaging for work (though I usually do all this through a docker container). Looking into cq-editor and cadquery it doesn’t look that difficult to package. I’ll create a PR in the next few minutes. I’m a materials engineer by background but I’ve been wanting to use CAD to model my house with exact measurements. This looks like an interesting way to programmatically generate my house.

Here is my initial attempt at packaging cq-editor [WIP] pythonPackages.cq-editor: init at 0.1RC1 by costrouc · Pull Request #65378 · NixOS/nixpkgs · GitHub. cqquery is complete but cq-editor needs a little work to get the tests passing.

1 Like

Thankyou! I don’t have time today but I’ll test it out soon!