Python dependencies in user profile

I recently installed a GUI programme to the user profile. I do not intend to use it in a particular environment, just have at hand for ad hoc tasks on my laptop. Turns out some of the functionalities fail since they cannot find certain Python libraries.

One such libraries is pyparsing, which on my system is available by default in any Python environment. Therefore I tried installing the Python package to the user profile:

$ nix profile install nixpkgs#python3

And yet the GUI programme keeps failing. What is the correct course of action in this case? Why aren’t Python libraries available to the programme installed to the user profile?

Thank you.

What you’re describing sounds like intended behaviour.

Python packages in nixpkgs (and packages in nixpkgs in general) do not source libraries from the environment. They source their dependencies from the list of build inputs specified for the package before it was built. The good part about this is that there are less cases of “it works on my machine” just because “my machine” happened to have some random package in its environment. The bad part is of course that it’s more hassle, but that is kinda the entire tradeoff you get by using this ecosystem.

It sounds like the bug in this case is that the nix package for your GUI program is missing some dependencies from its list of build inputs. It might also be that they have been marked optional, and requires you to enable some flags. Please consider opening an issue for it in nixpkgs if it happens to be the first case.

Thank you, that makes things clear. Regarding the missing flags hypothesis, how could I find those?

The flags would be in the arguments for the package in nixpkgs (could also be elsewhere if it’s coming from another flake input). I don’t know which program you are dealing with at the moment, but I could provide some examples.

  • An easy example could be gh-notify. It let’s you enable withBat and withDelta if you want those dependencies as well. You can enable them by swapping out gh-notify for (gh-notify.override { withBat = true; withDelta = true; }) in your configuration.

  • A much more extreme example is ffmpeg. It lets you enable/disable support for a ton of different media codecs.

  • Some packages like azure-cli might allow you to specify a list of plugin packages or extra libraries.