pythonpython-3.xjupyter-notebooknixosfacebook-prophet

NixOS: How to add prophet to Jupyter environment?


I'm using JupyterWith framework for the definition of declarative and reproducible Jupyter environments on Nix OS. Based on the documentation, I have created shell.nix file where I define all the python dependencies. And it works just fine:

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

  iPython = jupyter.kernels.iPythonWith {
    name = "python";
    packages = p: with p; [
      pandas
      numpy
      seaborn
      matplotlib
      scikitlearn
      # prophet
    ];
  };

  iHaskell = jupyter.kernels.iHaskellWith {
    extraIHaskellFlags = "--codemirror Haskell";
    name = "haskell";
    packages = p: with p; [ hvega formatting ];
  };

  jupyterEnvironment =
    jupyter.jupyterlabWith {
      kernels = [ iPython iHaskell ];
    };
in
  jupyterEnvironment.env

However, the problem occurs when I add prophet package as another python dependency. After that, when I try to run nix-shell I get the following error:

jbezdek@kraken:~$ nix-shell ~/shell.nix.jupyter
error: undefined variable 'prophet' at /home/jbezdek/shell.nix.jupyter:15:7
(use '--show-trace' to show detailed location information)

Can you help me what I am doing wrong, please?


Solution

  • As far as I can tell, you're not doing anything wrong here. The problem with prophet is more under-the-hood. The Python packages you can use with Nix are not the ones found on PyPI (through some sort of mirror) but rather are Nix derivations of the package source itself. This means that for a package to be usable with Nix, someone needs to have written a suitable derivation for that.

    All available packages on the standard nixpkgs-unstable and the stable channels can be searched for and found on search.nixos.org. When you type prophet there, you won't find it under the python3Packages package set, which means that nobody made an effort to write a derivation for it yet. So the best chance there would be to either start writing your own derivation (see the manual) or make a package request on the GitHub repo.