I am trying to run napari from a nix-shell. I’ve pip installed napari inside the shell, and hunted down many libraries which it requires, but now upon trying to run it I’m getting an ImportError
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
Does anyone know where this library can be sourced from? On other distros, Google tells me it comes from libglib
, but I can’t find this in the NixOS search.
It is glib
for NixOS. (edited)
You can check where libgthread-2.0.so.0
comes from with nix-locate
from nix-index project.
$ nix-locate "libgthread-2.0.so.0"
...
glib.out 0 s /nix/store/1pj0qrswyq0iyfa4xzqwppnfxszvh868-glib-2.70.0/lib/libgthread-2.0.so.0
glib.out 15,728 x /nix/store/1pj0qrswyq0iyfa4xzqwppnfxszvh868-glib-2.70.0/lib/libgthread-2.0.so.0.7000.0
...
2 Likes
ilkecan:
It is glibc
for NixOS.
Thank you - however I added this to my shell.nix
:
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
name = "pipzone";
targetPkgs = pkgs: (with pkgs; [
...
glibc
...
]);
runScript = "bash";
}).env
and am unfortunately still getting this ImportError
Thank you for this. This will save me a tonne of time in the future.
Maybe you can try adding it to LD_LIBRARY_PATH
, like:
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.glibc}/lib";
Thank you. I was using buildFHSUserEnv
so I did
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
name = "pipzone";
targetPkgs = pkgs: (with pkgs; [
...
glibc
...
]);
runScript = "bash";
profile = ''
export LD_LIBRARY_PATH=${pkgs.glibc}/lib
'';
}).env
Now I am missing libstdc++.so.6. I ran nix-locate "libstdc++.so.6"
, but the output is very long. How do I know where to look for the main library?
A side question: when getting programs to work, is this normal? The run -> error -> find & install library -> run
loop?
jtojnar
February 16, 2022, 9:00am
6
ilkecan:
It is glibc
for NixOS.
glib
, which contains libgthread
is different from glibc
.
2 Likes
Same problem here, libgthread-2.0.so.0
is provided by "${pkgs.glib.out}"
, I found it’s path by nix repl "<nixpkgs>"
:
› nix repl "<nixpkgs>"
Loading installable ''...
Added 17755 variables.
nix-repl> "${pkgs.glib.out}"
"/nix/store/phpj49r6iglnj5kpln2jrrwd21573q0k-glib-2.74.3"
check the shared library provided by this package:
› ls /nix/store/phpj49r6iglnj5kpln2jrrwd21573q0k-glib-2.74.3/lib
glib-2.0 libglib-2.0.so libgmodule-2.0.so.0 libgobject-2.0.so.0.7400.3
libgio-2.0.so libglib-2.0.so.0 libgmodule-2.0.so.0.7400.3 libgthread-2.0.so
libgio-2.0.so.0 libglib-2.0.so.0.7400.3 libgobject-2.0.so libgthread-2.0.so.0
libgio-2.0.so.0.7400.3 libgmodule-2.0.so libgobject-2.0.so.0 libgthread-2.0.so.0.7400.3
then fixed the problem temporarily by command:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/nix/store/phpj49r6iglnj5kpln2jrrwd21573q0k-glib-2.74.3/lib
2 Likes
I know this is a little old, but you can just export the path like this too:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.glib.out}/lib
Instead of messing with the library path, I personally prefer to use nix-ld system-wide to fix those kinds of issues. For libglib the catch is that pkgs.glib
is not in its defaults, so you have to add it to the list of covered libraries explicitly. The related part of my nixos-config looks like this:
{ options, pkgs, ... }:
{
programs.nix-ld = {
enable = true;
libraries = options.programs.nix-ld.libraries.default ++ (
with pkgs; [
glib # libglib-2.0.so.0, libgthread-2.0.so.0
]
);
};
}