python icon indicating copy to clipboard operation
python copied to clipboard

`pamela` broken (for `jupyterhub`)

Open quinn-dougherty opened this issue 2 years ago • 0 comments

In regards to https://github.com/on-nix/python/issues/11, it looks like the current best way to get a jupyter notebook through python.on-nix is to use jupyterhub.

When I try to run jupyterhub, it breaks at import pamela

[nix-shell:~/]$ jupyterhub
[I 2021-10-24 20:43:43.224 JupyterHub app:2459] Running JupyterHub version 1.4.2
[I 2021-10-24 20:43:43.224 JupyterHub app:2489] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.4.2
[I 2021-10-24 20:43:43.224 JupyterHub app:2489] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-1.4.2
[I 2021-10-24 20:43:43.225 JupyterHub app:2489] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-1.4.2
[I 2021-10-24 20:43:43.231 JupyterHub app:1534] Loading cookie_secret from /home/quinn//jupyterhub_cookie_secret
[I 2021-10-24 20:43:43.284 JupyterHub proxy:497] Generating new CONFIGPROXY_AUTH_TOKEN
[E 2021-10-24 20:43:43.285 JupyterHub app:2969]
    Traceback (most recent call last):
      File "/nix/store/2li4k7pbb0yx5a06cmdfpw2ili4fn1fl-jupyterhub-latest-python39-out/lib/python3.9/site-packages/jupyterhub/app.py", line 2966, in launch_instance_async
        await self.initialize(argv)
      File "/nix/store/2li4k7pbb0yx5a06cmdfpw2ili4fn1fl-jupyterhub-latest-python39-out/lib/python3.9/site-packages/jupyterhub/app.py", line 2505, in initialize
        await self.init_users()
      File "/nix/store/2li4k7pbb0yx5a06cmdfpw2ili4fn1fl-jupyterhub-latest-python39-out/lib/python3.9/site-packages/jupyterhub/app.py", line 1781, in init_users
        if self.authenticator.enable_auth_state:
      File "/nix/store/mj2kh9jl9nzz68n2dxa3xidl0rwnmlhh-traitlets-5.1.0-python39-out/lib/python3.9/site-packages/traitlets/traitlets.py", line 577, in __get__
        return self.get(obj, cls)
      File "/nix/store/mj2kh9jl9nzz68n2dxa3xidl0rwnmlhh-traitlets-5.1.0-python39-out/lib/python3.9/site-packages/traitlets/traitlets.py", line 540, in get
        default = obj.trait_defaults(self.name)
      File "/nix/store/mj2kh9jl9nzz68n2dxa3xidl0rwnmlhh-traitlets-5.1.0-python39-out/lib/python3.9/site-packages/traitlets/traitlets.py", line 1580, in trait_defaults
        return self._get_trait_default_generator(names[0])(self)
      File "/nix/store/mj2kh9jl9nzz68n2dxa3xidl0rwnmlhh-traitlets-5.1.0-python39-out/lib/python3.9/site-packages/traitlets/traitlets.py", line 977, in __call__
        return self.func(*args, **kwargs)
      File "/nix/store/2li4k7pbb0yx5a06cmdfpw2ili4fn1fl-jupyterhub-latest-python39-out/lib/python3.9/site-packages/jupyterhub/app.py", line 1071, in _authenticator_default
        return self.authenticator_class(parent=self, db=self.db)
      File "/nix/store/2li4k7pbb0yx5a06cmdfpw2ili4fn1fl-jupyterhub-latest-python39-out/lib/python3.9/site-packages/jupyterhub/auth.py", line 986, in __init__
        raise _pamela_error from None
      File "/nix/store/2li4k7pbb0yx5a06cmdfpw2ili4fn1fl-jupyterhub-latest-python39-out/lib/python3.9/site-packages/jupyterhub/auth.py", line 17, in <module>
        import pamela
      File "/nix/store/narw7qrnby9wrs84cj606flc2g2431wl-pamela-latest-python39-out/lib/python3.9/site-packages/pamela.py", line 158, in <module>
        PAM_STRERROR = LIBPAM.pam_strerror
      File "/nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/lib/python3.9/ctypes/__init__.py", line 387, in __getattr__
        func = self.__getitem__(name)
      File "/nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/lib/python3.9/ctypes/__init__.py", line 392, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: /nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/bin/python: undefined symbol: pam_strerror

So LIBPAM lacks the attribute pam_strerror. Some digging:

/nix/store/narw7qrnby9wrs84cj606flc2g2431wl-pamela-latest-python39-out/lib/python3.9/site-packages/pamela.py

LIBPAM = CDLL(find_library("pam"))

where find_library is imported from ctypes.util. I'm guessing it needs some c dependency (something called pam) that we don't have.

Any workaround ideas?

Minimal .nix file

{ pkgs ? import <nixpkgs> {} }:
let
  pythonOnNix = import
    (builtins.fetchGit {
      # Use `main` branch or a commit from this list:
      # https://github.com/on-nix/python/commits/main
      ref = "main";
      url = "https://github.com/on-nix/python";
    }) {};
  env = pythonOnNix.python39Env {
    name = "Danaswap-analytics";
    projects = {
      jupyterhub = "latest";
      pamela = "latest"; # needed for jupyterhub 
    };
  };
in env.dev

I'll update if changing python3xEnv digit changes anything.

quinn-dougherty avatar Oct 25 '21 00:10 quinn-dougherty