jupyenv icon indicating copy to clipboard operation
jupyenv copied to clipboard

package added with `packages` not available in kernel environment.

Open bj0 opened this issue 4 years ago • 3 comments

Describe the bug I tried to add multiple packages to the kernel environment, but some are missing.

To Reproduce I copied the getting started example and added 2 modules:

{ pkgs ? import (fetchTarball https://github.com/nixos/nixpkgs/archive/nixpkgs-unstable.tar.gz) {} }:

let
    jupyter = import (builtins.fetchGit {
        url = https://github.com/tweag/jupyterWith;
    }) {};

    iPython = jupyter.kernels.iPythonWith {
        name = "ipy";
        packages = p: with p; [ numpy coconut trio ];
    };

    jupyterEnvironment = jupyter.jupyterlabWith {
        kernels = [ iPython ];
        extraPackages = p: [ p.python3Packages.jupyter_console ];
    };

in
    jupyterEnvironment.env

when I try go into either jupyter console or jupyter lab, I can import numpy and trio, but coconut says no module found. There are no errors when starting with nix-shell.

Environment ubuntu 20.04 nix-shell (Nix) 2.4pre20210503_6d2553a

bj0 avatar Sep 30 '21 17:09 bj0

Hello, I am not well acquainted with coconut, but my impression is that it is an executable external to Python, am I correct? In this case I can understand why it doesn't show in Jupyter, since it is not a module.

guaraqe avatar Oct 04 '21 10:10 guaraqe

It is a module, the 'executable' is just a script that runs an interpreter from the module. They also have a jupyter kernel in the module. I was able to use mach-nix to get coconut and the kernel working, but I still don't understand why this didn't work. If it couldn't find the module I would have expected an error.

Here is what I used to get the kernel working. I mostly just use it for a jupyter console:

https://gist.github.com/bj0/aa1ed75920381144781baa669d0ed4c9

bj0 avatar Oct 04 '21 18:10 bj0

I think the problem is that python3Packages.coconut is defined using buildPythonApplication, so it does not get installed as a Python module, only as a binary. To be fair, looking at their docs, I don’t see anywhere any mention that it is supposed to be imported as a module.

I think, what you want is using it as a kernel.

kirelagin avatar Feb 03 '22 20:02 kirelagin

This will be fixed and documented with next version of jupyterWith (see main branch)

garbas avatar Aug 17 '22 20:08 garbas