Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyside on nixos ImportError: libgssapi_krb5.so.2 #492

Open
GlassGhost opened this issue Jul 15, 2022 · 13 comments
Open

Pyside on nixos ImportError: libgssapi_krb5.so.2 #492

GlassGhost opened this issue Jul 15, 2022 · 13 comments

Comments

@GlassGhost
Copy link
Contributor

Has anyone been using pyside on nixos? I'm trying to run an example from https://github.com/pyside/pyside2-examples

I used nix-locate -1 -w libgssapi_krb5.so.2 to decide I needed libkrb5 and krb5 in my configuration.nix and I'm still getting the error below.

Traceback (most recent call last):
  File "/home/owner/sync/Scripts/cards/pyside2-examples-dev/examples/tutorial/t5.py", line 47, in <module>
    from PySide2 import QtCore, QtGui, QtWidgets
ImportError: libgssapi_krb5.so.2: cannot open shared object file: No such file or directory```

here is my requirements.txt:

```PyOpenGL
# GitUrl: https://github.com/numpy/numpy.git
numpy >= 1.15
# GitUrl: https://github.com/pydata/pandas.git
pandas >= 1.3
# GitUrl: https://github.com/sphinx-doc/sphinx.git
sphinx >= 4.3
# GitUrl: https://github.com/benjaminp/six.git
six >= 1.15
# GitUrl: https://github.com/pyinstaller/pyinstaller.git
pyinstaller >= 4.8
# GitUrl: https://code.qt.io/cgit/pyside/pyside-setup.git
pyside2 >= 5.12
@GlassGhost
Copy link
Contributor Author

I even did a rm -rf ./env and a full mach-nix env ./env -r ./requirements.txt & nix-shell ./env after a nixos rebuild after putting libkrb5 and krb5 in conf.nix

@GlassGhost
Copy link
Contributor Author

If you have nix-index package installed you should be able to nix-locate -1 -w libgssapi_krb5.so.2 | grep -v \( to show the following packages should provide the libraries on the system

libkrb5.out
krb5.out
hyperion-ng.out

and I have libkrb5 and krb5 in my packages in my configuration.nix

and it still doesn't work

@bjornfor
Copy link
Contributor

(mach-nix user here.)

Can you paste your Nix expression?

@GlassGhost
Copy link
Contributor Author

I just entered the commands above I listed and have the requirements.txt and it generated my shell.nix file.

here is my env directory

@bjornfor
Copy link
Contributor

I just entered the commands above I listed and have the requirements.txt and it generated my shell.nix file.

Ah, sorry I missed that.

I think what you found is that python packaging metadata doesn't include OS/system library dependencies, so you have to write a Nix expression and add that info manually with an overlay. Example here: https://github.com/DavHau/mach-nix/blob/master/examples.md#example-add-missing-build-inputs.

@bjornfor
Copy link
Contributor

and I have libkrb5 and krb5 in my packages in my configuration.nix

and it still doesn't work

If you're talking about environment.systemPackages, then NixOS doesn't generally work that way. If you put libraries there they won't be visible to the rest of the system automatically. That's by design, to avoid dependency hell. That option is for packages -- things to have in $PATH or in desktop launchers.

@bjornfor
Copy link
Contributor

Anyway, taking your env/python.nix as base:

with (import ./inputs.nix);
mach-nix.mkPython {
  requirements = builtins.readFile ./requirements.txt;
}

and tweak it like this:

with (import ./inputs.nix);
mach-nix.mkPython {
  requirements = builtins.readFile ./requirements.txt;
  _.pyside2.buildInputs.add = with pkgs; [ libkrb5 ];  # LINE ADDED
}

then it works:

$ cd env && nix-shell --run 'python3 -c "from PySide2 import QtCore, QtGui, QtWidgets"'
(no error, exits successfully)

@GlassGhost
Copy link
Contributor Author

Thanks works great now!

is there anyway to make mach nix detect and add this lib if the library is in the requirements.txt or is this standard procedure

I added a pull request; #495

To help others in this situation. I just realized the suggested method to find libs only works on nixos, but I think that should be enough for now.

@bjornfor
Copy link
Contributor

is there anyway to make mach nix detect and add this lib if the library is in the requirements.txt or is this standard procedure

I think autoPatchelfHook can be told to fail if it's missing libs, but it only works for non-dlopen() libs. Also, mach-nix contains a list of overrides for packages that has native library dependencies. You can create a PR to make pyside2 require libkrb5 so that it works out of the box. See example here: 627ca70.

I think the documentation already covers adding missing libraries. (That's how I learned about it.)

I added a pull request; #495

To help others in this situation. I just realized the suggested method to find libs only works on nixos, but I think that should be enough for now.

I don't see anything in that PR that makes it NixOS specific.

@bjornfor
Copy link
Contributor

You can create a PR to make pyside2 require libkrb5 so that it works out of the box. See example here: 627ca70.

But note that libkrb5 should be in buildInputs (not nativeBuildInputs).

@GlassGhost
Copy link
Contributor Author

@bjornfor

Ok so I think you're saying the proper way to fix this is to modify /mach_nix/fixes.nix

pyside2.add-native-inputs = {
_cond = { prov, ver, ... }: prov == "sdist";
nativeBuildInputs.add = with pkgs; [ libkrb5 libsForQt5.full ];
};

I will try this later, but this does look better?

@bjornfor
Copy link
Contributor

  • I think prov == "sdist" should be changed to prov != "nixpkgs".
  • s/nativeBuildInputs/buildInputs/
  • I didn't know you needed libsForQt5.full... didn't it work with only libkrb5? I'm afraid that pulling in Qt from nixpkgs cause conflicts with the pre-built wheels from pypi.

GlassGhost added a commit to GlassGhost/mach-nix that referenced this issue Aug 8, 2022
@GlassGhost
Copy link
Contributor Author

Ok I was trying my own clone of mach in directory /home/owner/mach-nix/ and these commands:

nix-env --uninstall mach-nix-master
nix-env -if /home/owner/mach-nix/ -A mach-nix

I tried many different combinations of

  pyside2.add-native-inputs = {
    _cond = { prov, ver, ... }: prov != "nixpkgs";
    buildInputs.add = with pkgs; [ libkrb5 qt5Full ];
  };

just trying to help in case anyone else is trying to get it to work with a simple requirements.txt
Don't worry about me, I can get it to work is with added custom line in python.nix and yes it was getting errors without the qt5Full I believe pyside2 is qt5 and pyside 6 is qt6

_.pyside2.buildInputs.add = with pkgs; [ libkrb5 qt5Full ]; # LINE that worked in python.nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants