For some time now I noticed that I was having trouble configuring my Python3 package via home-manager. I was able to “resolve” the issue temporarily but now I’ve looked into fixing the underlying problem and I’m stuck.
The situation is that I am interested in adding modules to python3 (pandas and numpy, for example). To do so, and as I could find in the Wiki, I added the following to my home.packages:
(python3.withPackages (pkgs: with pkgs; [ pandas numpy ]))
After making the switch, however, the packages are not available when I interactively run python3 in the terminal. It was strange because adding an equivalent expression to my configuration.nix to apply the switch globally, it worked perfectly when using sudo (I only did it to test. I wanted to know if the expression worked fine).
Just yesterday I managed to find this related post " Python3 not importing modules", where the creator has a similar problem to mine and it seems that in his case terminator was interfering in which python3 to use. However in my case it is not terminator but systemd-boot who is masking python3.
Taking advantage of the discussion in the post and the commands with which they helped him diagnose the case, I got the following:
- nix-env is NOT masking my Python3:
❯ nix-env --query home-manager-path
- Python3 and numpy are not on the same path. (It was striking to me that the package that produces the conflict in the case of the other user, and me, is exactly the same when comparing hashes, but I don’t know if it’s relevant)
❯ readlink -f $(which python3) /nix/store/sz0j8k8ljh7y8qgyfxgqb3ws11bcy4gs-python3-3.10.6/bin/python3.10 ❯ readlink -f $(which f2py) /nix/store/ghqqfq4f9n3fjb4l9cdd1pqhm4j91swd-python3-3.10.6-env/bin/f2py
- Python3 is being a dependency of systemd-boot (…if I understand correctly).
❯ nix why-depends /run/current-system /nix/store/sz0j8k8ljh7y8qgyfxgqb3ws11bcy4gs-python3-3.10.6 /nix/store/mjb1w8qri7giahh42hfh4iqrn5xd7xf5-nixos-system-wiseh-22.11.20220922.ae1dc13 └───/nix/store/7nc054hg8d6srbp6b3q36gs3msawaq45-systemd-boot └───/nix/store/sz0j8k8ljh7y8qgyfxgqb3ws11bcy4gs-python3-3.10.6
After discovering that I thought about, for example, changing systemd-boot to grub and see if the problem was solved. Honestly it was an odyssey trying to configure grub to work with UEFI as it always ended up in a shell and did not run my graphical environment so I could not test my hypothesis; but, besides, I would rather understand and correct the problem with systemd-boot as I want to continue using it (and it seems better than running away from the mishap).
I really appreciate if someone can help me with what my next step should be, and if more information is needed I’ll stay tuned.